pkgsrc/security/tripwire/patches/patch-af
ben 4865884f55 Update the format string in dbase.build.c also.
Fix the format string and types to work on older versions of NetBSD, in
addition to FreeBSD and SunOS.
2003-12-09 19:17:37 +00:00

81 lines
3 KiB
Text

$NetBSD: patch-af,v 1.2 2003/12/09 19:17:37 ben Exp $
--- src/dbase.build.c.orig 1994-07-25 08:24:09.000000000 -0700
+++ src/dbase.build.c
@@ -66,7 +66,6 @@ static char rcsid[] = "$Id: dbase.build.
int files_scanned_num = 0;
/* prototypes */
-char *mktemp();
static void database_record_write();
char backupfile[MAXPATHLEN+256];
@@ -92,6 +91,7 @@ database_build (pp_list, mode, pp_entry_
{
struct list_elem *p_fileentry;
struct list_elem *p_configentry;
+ int fdw;
FILE *fpw;
char database[MAXPATHLEN+256];
int entrynum,
@@ -130,11 +130,12 @@ database_build (pp_list, mode, pp_entry_
die_with_err("malloc() failed in database_build", (char *) NULL);
(void) strcpy(tmpfilename, TEMPFILE_TEMPLATE);
- if ((char *) mktemp(tmpfilename) == NULL)
- die_with_err("database_build: mktemp()", (char *) NULL);
+ fdw = mkstemp(tmpfilename);
+ if (fdw == -1)
+ die_with_err("database_build: mkstemp()", (char *) NULL);
+ unlink(tmpfilename);
- (void) strcpy(tempdatabase_file, tmpfilename);
- (void) strcpy(database, tempdatabase_file);
+ (void) strcpy(database, tmpfilename);
free(tmpfilename);
} /* end if temporary database */
else if (mode == DBASE_UPDATE) {
@@ -224,6 +225,11 @@ printf("database_build(): ---> olddataba
}
/* rebuild the database */
+ if (mode == DBASE_TEMPORARY) {
+ fpw = fdopen(fdw, "w+");
+ if (fpw == NULL)
+ die_with_err("call fdopen() failed.", NULL);
+ } else
if ((fpw = fopen(database, "w")) == NULL)
die_with_err("Hint: Maybe the database directory '%s' doesn't exist? fopen()", database);
@@ -367,10 +373,10 @@ printf("--(contents)-->%s\n", entry);
die_with_err("database_build: list_close() failed!\n", (char *) NULL);
}
- /* we don't want to allow anyone to spoof the temporary file in /tmp */
+ /* If the database was temporary, the file was unlink()ed, and is
+ "hidden" from other processes. */
if (mode == DBASE_TEMPORARY) {
- if ((fptempdbase = freopen(database, "r", fpw)) == NULL)
- die_with_err("temporary database file disappeared?!?", database);
+ fptempdbase = fpw;
rewind(fptempdbase);
} else {
fclose(fpw);
@@ -413,7 +419,7 @@ database_record_write (fpw, filename, fl
/* filename, entrynum, ignore, mode, inode, nlinks, uid, gid, size,
* access, modify, ctime, {sig0, sig1, ..., sig9}
*/
- static char *format = "%s %ld %s %lo %ld %ld %ld %ld %ld %s %s %s %s\n";
+ static char *format = "%s %d %s %o %u %u %u %u %lld %s %s %s %s\n";
/* initialize our temporary file */
if (fdsymlink == -1) {
@@ -541,7 +547,7 @@ SKIPPED_SIGS:
fprintf(fpw, format, filename_escape(filename), (int32)entrynum, ignorevec,
(int32)statbuf->st_mode, (int32)statbuf->st_ino,
(int32)statbuf->st_nlink, (int32)statbuf->st_uid,
- (int32)statbuf->st_gid, (int32)statbuf->st_size,
+ (int32)statbuf->st_gid, (long long)statbuf->st_size,
pltob64((uint32 *) &va, (char *) vec64_a, 1),
pltob64((uint32 *) &vm, (char *) vec64_m, 1),
pltob64((uint32 *) &vc, (char *) vec64_c, 1),