Browse Source

Fix read past buffer in lib/nfmalloc.c.

Adam Heath 24 years ago
parent
commit
29d0e3357e
3 changed files with 7 additions and 5 deletions
  1. 4 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 2 5
      lib/nfmalloc.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Thu Aug 22 23:25:23 CDT 2002 Adam Heath <doogie@debian.org>
+
+  * lib/nfmalloc.c: Fix read past buffer in lib/nfmalloc.c.
+
 Thu Aug 22 23:16:02 CDT 2002 Adam Heath <doogie@debian.org>
 
   * utils/md5sum.c: Handle directories better in md5sum.

+ 1 - 0
debian/changelog

@@ -4,6 +4,7 @@ dpkg (1.10.5) unstable; urgency=low
     Closes: #154503.
   * Fix extraction of md5sum in dpkg-scanpackages.  Closes: #153769.
   * Handle directories better in md5sum.  Closes: #157453.
+  * Fix read past buffer in lib/nfmalloc.c.  Closes: #157304.
 
  -- Adam Heath <doogie@debian.org>  UNRELEASED
 

+ 2 - 5
lib/nfmalloc.c

@@ -53,15 +53,12 @@ inline void *nfmalloc(size_t size)
 
 char *nfstrsave(const char *string) {
   OBSTACK_INIT;
-  return obstack_copy (&db_obs, string, strlen(string) + 1);
+  return obstack_copy0 (&db_obs, string, strlen(string));
 }
 
 char *nfstrnsave(const char *string, int l) {
-  char *ret;
   OBSTACK_INIT;
-  ret = obstack_copy (&db_obs, string, l + 1);
-  *(ret + l) = 0;
-  return ret;
+  return obstack_copy0 (&db_obs, string, l);
 }
 
 void nffreeall(void) {