nwrap: Check paramters and make sure return values are zeored
authorAndreas Schneider <asn@samba.org>
Thu, 19 Mar 2020 08:16:24 +0000 (09:16 +0100)
committerAndreas Schneider <asn@samba.org>
Thu, 19 Mar 2020 08:49:39 +0000 (09:49 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@suse.de>
src/nss_wrapper.c

index 5d3a01c5ce3f826d2b4a37d4ae95eea00f40fe9f..15bd99f4e86c08be723f67a75919f3853fdf9510 100644 (file)
@@ -3727,6 +3727,13 @@ static int nwrap_files_gethostbyname2_r(struct nwrap_backend *b,
        (void) b; /* unused */
        (void) af; /* unused */
 
+       if (name == NULL || hedst == NULL || buf == NULL || buflen == 0) {
+               errno = EINVAL;
+               return -1;
+       }
+       *hedstp = NULL;
+       buf[0] = '\0';
+
        addr_list = calloc(1, sizeof(struct nwrap_vector));
        if (addr_list == NULL) {
                NWRAP_LOG(NWRAP_LOG_ERROR,