Browse Source

libdpkg: Fix off-by-one error in command argv size calculation

We need a ghost byte for the terminating NUL character, so add it up
to the requested needed bytes.

Closes: #760690

Warned-by: valgrind
Based-on-patch-by: Bálint Réczey <balint@balintreczey.hu>
Guillem Jover 11 years ago
parent
commit
9b9acf81ba
2 changed files with 5 additions and 0 deletions
  1. 2 0
      debian/changelog
  2. 3 0
      lib/dpkg/command.c

+ 2 - 0
debian/changelog

@@ -106,6 +106,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
   * Add --build and --extract command aliases to dpkg-source.
   * Print file or package names instead of pointers in dpkg debug output,
     to make it more meaningful and reproducible.
+  * Fix off-by-one error in libdpkg command argv size calculation.
+    Based on a patch by Bálint Réczey <balint@balintreczey.hu>. Closes: #760690
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 3 - 0
lib/dpkg/command.c

@@ -77,6 +77,9 @@ command_destroy(struct command *cmd)
 static void
 command_grow_argv(struct command *cmd, int need)
 {
+	/* We need a ghost byte for the NUL character. */
+	need++;
+
 	/* Check if we already have enough room. */
 	if ((cmd->argv_size - cmd->argc) >= need)
 		return;