NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/51040: Fix memory leak in makemandb(8)
>Number: 51040
>Category: bin
>Synopsis: Fix memory leak in makemandb(8)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 03 10:55:00 +0000 2016
>Originator: Abhinav Upadhyay
>Release: CURRENT
>Organization:
>Environment:
>Description:
As per the libarchive(3) man page, we should call archive_read_finish(3) once we are done reading the stream in order to free up the resources allocated by libarchive. archive_read_finish(3) implicitly calls archive_read_close(3) if it was not called manually.
In makemandb(8) only archive_read_close(3) is called inside the read_and_decompress function, I think it would result in memory leakage.
The attached patch should fix it.
>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 10:51:33 -0000
@@ -702,7 +702,7 @@
for (;;) {
r = archive_read_data(a, buf + off, *len - off);
if (r == ARCHIVE_OK) {
- archive_read_close(a);
+ archive_read_finish(a);
*bufp = buf;
*len = off;
return 0;
@@ -718,7 +718,7 @@
if (mflags.verbosity)
warnx("File too large: %s", file);
free(buf);
- archive_read_close(a);
+ archive_read_finish(a);
return -1;
}
buf = erealloc(buf, *len);
@@ -727,7 +727,7 @@
archive_error:
warnx("Error while reading `%s': %s", file, archive_error_string(a));
- archive_read_close(a);
+ archive_read_finish(a);
return -1;
}
Home |
Main Index |
Thread Index |
Old Index