$OpenBSD: patch-decode_c,v 1.1 2002/08/09 01:15:19 naddy Exp $
--- decode.c.orig	Thu Feb 16 22:39:44 1995
+++ decode.c	Fri Aug  9 03:03:32 2002
@@ -28,10 +28,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
+#include <md5.h>
 #include "xmalloc.h"
 #include "common.h"
 #include "part.h"
-#include "md5.h"
 
 extern char *os_idtodir();
 extern FILE *os_newtypedfile();
@@ -416,6 +416,15 @@ char **headerp;
 	}
 	if (*header) *header++ = '\0';
     }
+
+    /*
+     * Debian fix: if there was only an empty parameter list (a bare
+     * semicolon) then there is no guarantee that param[nparam] exists.
+     * Therefore, treat it as if there is no parameter list.
+     */
+    if (nparam == 0)
+	return 0;
+
     param[nparam] = 0;
     return param;
 }
@@ -466,6 +475,7 @@ char *key;
 	while (*from && *from != '\"') {
 	    if (!--left) {
 		alloced += VALUEGROWSIZE;
+		left += VALUEGROWSIZE;
 		value = xrealloc(value, alloced);
 		to = value + alloced - left - 2;
 	    }
@@ -482,6 +492,7 @@ char *key;
 	while (*from && !isspace(*from)) {
 	    if (!--left) {
 		alloced += VALUEGROWSIZE;
+		left += VALUEGROWSIZE;
 		value = xrealloc(value, alloced);
 		to = value + alloced - left - 2;
 	    }
@@ -571,6 +582,7 @@ char *disposition;
 	while (*disposition && *disposition != '\"') {
 	    if (!--left) {
 		alloced += VALUEGROWSIZE;
+		left += VALUEGROWSIZE;
 		value = xrealloc(value, alloced);
 		to = value + alloced - left - 2;
 	    }
@@ -588,6 +600,7 @@ char *disposition;
 	       *disposition != '(') {
 	    if (!--left) {
 		alloced += VALUEGROWSIZE;
+		left += VALUEGROWSIZE;
 		value = xrealloc(value, alloced);
 		to = value + alloced - left - 2;
 	    }
