1 Greg Kroah-Hartman's patch, dated 8 Jan 2001.
2 diff -aur apache_1.3.14/src/support/htdigest.c apache_1.3.14-mkstemp/src/support/htdigest.c
3 --- apache_1.3.14/src/support/htdigest.c Tue Jan 25 23:36:53 2000
4 +++ apache_1.3.14-mkstemp/src/support/htdigest.c Tue Jan 9 20:42:42 2001
7 #define MAX_STRING_LEN 256
10 +char tn[MAX_STRING_LEN];
13 static void getword(char *word, char *line, char stop)
15 ap_getpass("Re-type new password: ", pwv, sizeof(pwv));
16 if (strcmp(pwin, pwv) != 0) {
17 fprintf(stderr, "They don't match, sorry.\n");
24 static void interrupted(void)
26 fprintf(stderr, "Interrupted.\n");
33 char x[MAX_STRING_LEN];
34 char command[MAX_STRING_LEN];
39 + strcpy (tn, "/tmp/htdigest-XXXXXX");
40 signal(SIGINT, (void (*)(int)) interrupted);
42 if (strcmp(argv[1], "-c"))
48 - if (!(tfp = fopen(tn, "w"))) {
51 + fprintf(stderr, "Could not open temp file.\n");
54 + if (!(tfp = fdopen(tfd, "w"))) {
55 fprintf(stderr, "Could not open temp file.\n");
58 diff -aur apache_1.3.14/src/support/htpasswd.c apache_1.3.14-mkstemp/src/support/htpasswd.c
59 --- apache_1.3.14/src/support/htpasswd.c Thu Jun 1 19:42:33 2000
60 +++ apache_1.3.14-mkstemp/src/support/htpasswd.c Tue Jan 9 20:41:36 2001
62 * This needs to be declared statically so the signal handler can
65 -static char *tempfilename;
66 +static char tempfilename[MAX_STRING_LEN];
68 * If our platform knows about the tmpnam() external buffer size, create
69 * a buffer to pass in. This is needed in a threaded environment, or
71 static void interrupted(void)
73 fprintf(stderr, "Interrupted.\n");
74 - if (tempfilename != NULL) {
75 + if (strlen(tempfilename) > 0) {
78 exit(ERR_INTERRUPTED);
80 int noninteractive = 0;
85 + memset (tempfilename, 0x00, sizeof(tempfilename));
87 - tempfilename = NULL;
88 signal(SIGINT, (void (*)(int)) interrupted);
92 * to add or update. Let's do it..
95 - tempfilename = tmpnam(tname_buf);
96 - if ((tempfilename == NULL) || (*tempfilename == '\0')) {
97 + strcpy(tempfilename, "/tmp/htpasswd-XXXXXX");
98 + tfd = mkstemp(tempfilename);
100 fprintf(stderr, "%s: unable to generate temporary filename\n",
107 - ftemp = fopen(tempfilename, "w+");
108 + ftemp = fdopen(tfd, "w+");
110 fprintf(stderr, "%s: unable to create temporary file '%s'\n", argv[0],