r9439: Make sure the remainder of the array is always initialized if the buffer is
authorJelmer Vernooij <jelmer@samba.org>
Sat, 20 Aug 2005 23:36:43 +0000 (23:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:14 +0000 (13:34 -0500)
larger then the string to be pushed.
(This used to be commit 70b52e26f31b00637ed7f90f77ff0b2794dad729)

source4/librpc/ndr/ndr_string.c

index 50fa887a34270e6bd0e49314e4e9cec108e2a79b..f5f128574d4dde5b3948c49e7408a26371369abc 100644 (file)
@@ -650,7 +650,13 @@ NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var,
                return ndr_push_error(ndr, NDR_ERR_CHARCNV, 
                                      "Bad character conversion");
        }
-       ndr->offset += ret;
+
+       /* Make sure the remaining part of the string is filled with zeroes */
+       if (ret < (byte_mul*length)) {
+               memset(ndr->data+ndr->offset+ret, 0, (byte_mul*length)-ret);
+       }
+
+       ndr->offset += length;
 
        return NT_STATUS_OK;
 }