FreeBSD Bugzilla – Attachment 7967 Details for
Bug 16929
[PATCH] prevent possible race condition in sort
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.19 KB, created by
spock
on 2000-02-23 07:00:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
spock
Created:
2000-02-23 07:00:01 UTC
Size:
2.19 KB
patch
obsolete
>Index: gnu/usr.bin/sort/sort.c >=================================================================== >RCS file: /home/ncvs/src/gnu/usr.bin/sort/sort.c,v >retrieving revision 1.15 >diff -u -r1.15 sort.c >--- sort.c 1999/04/25 22:14:05 1.15 >+++ sort.c 2000/02/23 06:45:13 >@@ -171,6 +171,8 @@ > > /* Prefix for temporary file names. */ > static char *temp_file_prefix; >+/* Temporary dir for temp files, *with* above prefix */ >+static char *temp_dir = NULL; > > /* Flag to reverse the order of all comparisons. */ > static int reverse; >@@ -288,6 +290,9 @@ > > for (node = temphead.next; node; node = node->next) > unlink (node->name); >+ if( temp_dir ) >+ rmdir(temp_dir); >+ > } > > /* Allocate N bytes of memory dynamically, with error checking. */ >@@ -413,6 +418,7 @@ > } > } > >+#define DIR_TEMPLATE "sortXXXXXXXXXX" > /* Return a name for a temporary file. */ > > static char * >@@ -420,15 +426,29 @@ > { > static unsigned int seq; > int len = strlen (temp_file_prefix); >- char *name = xmalloc (len + 1 + sizeof ("sort") - 1 + 5 + 5 + 1); >+ char *name=xmalloc(len + 1 + sizeof(DIR_TEMPLATE)-1 + 1 + sizeof("sort")-1 + 5 + 5 + 1); > struct tempnode *node; > > node = (struct tempnode *) xmalloc (sizeof (struct tempnode)); >+ if( !temp_dir ) >+ { >+ temp_dir = xmalloc( len + 1 + sizeof(DIR_TEMPLATE) ); >+ sprintf(temp_dir, >+ "%s%s%s", >+ temp_file_prefix, >+ (len && temp_file_prefix[len - 1] != '/') ? "/" : "", >+ DIR_TEMPLATE); >+ if( mkdtemp(temp_dir) == NULL ) >+ { >+ error(0, errno, _("can't make temp dir")); >+ exit(2); >+ } >+ } >+ > sprintf (name, >- "%s%ssort%5.5d%5.5d", >- temp_file_prefix, >- (len && temp_file_prefix[len - 1] != '/') ? "/" : "", >- (unsigned int) getpid () & 0xffff, seq); >+ "%s/sort%5.5d%5.5d", >+ temp_dir, >+ (unsigned int) getpid () & 0xffff, seq); > > /* Make sure that SEQ's value fits in 5 digits. */ > ++seq;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 16929
: 7967