NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/51039: makemandb(8): Check for return value of chdir(2)
>Number: 51039
>Category: bin
>Synopsis: makemandb(8): Check for return value of chdir(2)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 03 00:10:00 +0000 2016
>Originator: Abhinav Upadhyay
>Release: CURRENT
>Organization:
>Environment:
>Description:
makemandb makes a call to chdir(2) before parsing each page but the return value of chdir is not checked. We should check the return status and handle the error.
>How-To-Repeat:
>Fix:
Index: makemandb.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makemandb/makemandb.c,v
retrieving revision 1.33
diff -u -r1.33 makemandb.c
--- makemandb.c 31 Mar 2016 20:17:58 -0000 1.33
+++ makemandb.c 3 Apr 2016 00:02:20 -0000
@@ -842,12 +842,19 @@
* This means is either a new file or an updated file.
* We should go ahead with parsing.
*/
+ if (chdir(parent) != 0) {
+ if (mflags.verbosity)
+ warn("chdir failed for %s, could not index %s", parent, file);
+ err_count++;
+ free(md5sum);
+ continue;
+ }
+
if (mflags.verbosity == 2)
printf("Parsing: %s\n", file);
rec->md5_hash = md5sum;
rec->file_path = estrdup(file);
// file_path is freed by insert_into_db itself.
- chdir(parent);
begin_parse(file, mp, rec, buf, buflen);
if (insert_into_db(db, rec) < 0) {
if (mflags.verbosity)
Home |
Main Index |
Thread Index |
Old Index