ndr basic: Check ndr_token_store return code
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 7 Jan 2020 20:39:30 +0000 (09:39 +1300)
committerGary Lockyer <gary@samba.org>
Thu, 9 Jan 2020 21:49:00 +0000 (21:49 +0000)
Fix for

*** CID 1457529:  Error handling issues  (CHECKED_RETURN)
/librpc/ndr/ndr_basic.c: 786 in ndr_push_full_ptr()
...
ID 1457529:  Error handling issues  (CHECKED_RETURN)
    Calling "ndr_token_store" without checking return value (as is done
    elsewhere 14 out of 17 times).

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Thu Jan  9 21:49:00 UTC 2020 on sn-devel-184

librpc/ndr/ndr_basic.c

index 5c717e698583dcbffba476e8a1c51a3e30270925..0811a5909719dbf7ecbfa3baa4ebf98d089f555e 100644 (file)
@@ -781,9 +781,13 @@ _PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p
                /* Check if the pointer already exists and has an id */
                ptr = ndr_token_peek(&ndr->full_ptr_list, p);
                if (ptr == 0) {
+                       enum ndr_err_code ret = NDR_ERR_SUCCESS;
                        ndr->ptr_count++;
                        ptr = ndr->ptr_count;
-                       ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr);
+                       ret = ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr);
+                       if (ret != NDR_ERR_SUCCESS) {
+                               return ret;
+                       }
                }
        }
        return ndr_push_uint3264(ndr, NDR_SCALARS, ptr);