librpc/ndr: don't overwrite the content in ndr_push_relative_ptr2_end()
authorStefan Metzmacher <metze@samba.org>
Fri, 19 Feb 2010 07:11:24 +0000 (08:11 +0100)
committerKarolin Seeger <kseeger@samba.org>
Fri, 19 Feb 2010 11:30:46 +0000 (12:30 +0100)
metze
(cherry picked from commit 76aa37f653fec2d511921768381db7da661750cb)

The last 25 patches address bug #6888 (REGRESSION: printing support for 64 bit
windows clients broken).

librpc/ndr/ndr.c

index ab4168a0f9447bfd8bcec216fd742d5cd7d383e8..7d91d23eb81196f8cd73caa3146a253e95d26659 100644 (file)
@@ -1171,11 +1171,17 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, cons
        }
 
        if (len > 0) {
+               uint32_t clear_size = correct_offset - begin_offset;
+
+               clear_size = MIN(clear_size, len);
+
                /* now move the marshalled buffer to the end of the main buffer */
                memmove(ndr->data + correct_offset, ndr->data + begin_offset, len);
 
-               /* and wipe out old buffer within the main buffer */
-               memset(ndr->data + begin_offset, '\0', len);
+               if (clear_size) {
+                       /* and wipe out old buffer within the main buffer */
+                       memset(ndr->data + begin_offset, '\0', clear_size);
+               }
        }
 
        /* and set the end offset for the next buffer */