Zero fill the allocated memory for new `struct cifs_ntsd`
authormisku <miskuu@gmail.com>
Wed, 31 Jul 2019 11:12:24 +0000 (13:12 +0200)
committerPavel Shilovsky <pshilov@microsoft.com>
Wed, 7 Aug 2019 21:52:26 +0000 (14:52 -0700)
Fixes a bug where `sacloffset` may not be set at all later on and therefore it
can contain the original memory contents == trash.

setcifsacl.c

index da1d7425d74f38327e2e2d102d92fe258c396c39..f3d01894c1b54b81311dbbefef8d4b0b325f8cd5 100644 (file)
@@ -206,7 +206,7 @@ alloc_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd **npntsd,
        acessize = aces * sizeof(struct cifs_ace);
        bufsize = size + acessize;
 
-       *npntsd = malloc(bufsize);
+       *npntsd = calloc(1, bufsize);
        if (!*npntsd) {
                printf("%s: Memory allocation failure", __func__);
                return errno;