Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Check return value of fseek.
details: https://anonhg.NetBSD.org/src/rev/e5dfe4cf81dc
branches: trunk
changeset: 352982:e5dfe4cf81dc
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 16 20:49:09 2017 +0000
description:
Check return value of fseek.
CID 975275
CID 975276
diffstat:
usr.bin/make/arch.c | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diffs (90 lines):
diff -r a43c82dca01c -r e5dfe4cf81dc usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sun Apr 16 20:38:18 2017 +0000
+++ b/usr.bin/make/arch.c Sun Apr 16 20:49:09 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */
+/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -679,7 +679,8 @@
if (fread(memName, elen, 1, arch) != 1)
goto badarch;
memName[elen] = '\0';
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0)
+ goto badarch;
if (DEBUG(ARCH) || DEBUG(MAKE)) {
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
}
@@ -690,7 +691,8 @@
Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0)
+ goto badarch;
}
fclose(arch);
@@ -909,7 +911,10 @@
* the file at the actual member, rather than its header, but
* not here...
*/
- fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
} else
@@ -939,10 +944,17 @@
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
- fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr) - elen,
+ SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
goto skip;
} else
#endif
@@ -957,7 +969,10 @@
*/
arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
size = (int)strtol(arhPtr->ar_size, NULL, 10);
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
}
}
Home |
Main Index |
Thread Index |
Old Index