Module Name: src Committed By: abhinav Date: Tue May 2 13:54:08 UTC 2017
Modified Files: src/usr.sbin/makemandb: makemandb.c Log Message: We do need to copy the return value from dirname(3) since there it is a static buffer and can be overwritten in between. I overzealously removed this in one of my previous commits. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/makemandb/makemandb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/makemandb/makemandb.c diff -u src/usr.sbin/makemandb/makemandb.c:1.53 src/usr.sbin/makemandb/makemandb.c:1.54 --- src/usr.sbin/makemandb/makemandb.c:1.53 Mon May 1 06:56:00 2017 +++ src/usr.sbin/makemandb/makemandb.c Tue May 2 13:54:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $ */ +/* $NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $ */ /* * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com> * Copyright (c) 2011 Kristaps Dzonsons <krist...@bsd.lv> @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $"); +__RCSID("$NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $"); #include <sys/stat.h> #include <sys/types.h> @@ -450,9 +450,10 @@ main(int argc, char *argv[]) while ((len = getline(&line, &linesize, file)) != -1) { /* Replace the new line character at the end of string with '\0' */ line[len - 1] = '\0'; - char *pdir = dirname(line); + char *pdir = estrdup(dirname(line)); /* Traverse the man page directories and parse the pages */ traversedir(pdir, line, db, mp); + free(pdir); } free(line);