s3-net: Check return values of push_reg_sz().
authorAndreas Schneider <asn@samba.org>
Fri, 14 Dec 2012 17:07:10 +0000 (18:07 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 21 Dec 2012 12:56:00 +0000 (13:56 +0100)
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source3/utils/net_rpc_printer.c

index 0ab08efcc0a1981e575c3d4ea1aab684eb11f5ac..4fbe14f294c863ae0ae9b64b73c03f16d141ee30 100644 (file)
@@ -2512,6 +2512,8 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
                                struct registry_value value;
                                const char *value_name = info[j].value_name;
 
                                struct registry_value value;
                                const char *value_name = info[j].value_name;
+                               bool ok;
+
                                value.type = REG_SZ;
 
                                /* although samba replies with sane data in most cases we
                                value.type = REG_SZ;
 
                                /* although samba replies with sane data in most cases we
@@ -2519,7 +2521,11 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
                                if (strequal(value_name, SPOOL_REG_PORTNAME)) {
                                        /* although windows uses a multi-sz, we use a sz */
 
                                if (strequal(value_name, SPOOL_REG_PORTNAME)) {
                                        /* although windows uses a multi-sz, we use a sz */
-                                       push_reg_sz(mem_ctx, &value.data, SAMBA_PRINTER_PORT_NAME);
+                                       ok = push_reg_sz(mem_ctx, &value.data, SAMBA_PRINTER_PORT_NAME);
+                                       if (!ok) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
                                }
                                else if (strequal(value_name, SPOOL_REG_UNCNAME)) {
                                        char *unc_name;
                                }
                                else if (strequal(value_name, SPOOL_REG_UNCNAME)) {
                                        char *unc_name;
@@ -2527,7 +2533,11 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                                                nt_status = NT_STATUS_NO_MEMORY;
                                                goto done;
                                        }
                                                nt_status = NT_STATUS_NO_MEMORY;
                                                goto done;
                                        }
-                                       push_reg_sz(mem_ctx, &value.data, unc_name);
+                                       ok = push_reg_sz(mem_ctx, &value.data, unc_name);
+                                       if (!ok) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
                                        free(unc_name);
                                }
                                else if (strequal(value_name, SPOOL_REG_URL)) {
                                        free(unc_name);
                                }
                                else if (strequal(value_name, SPOOL_REG_URL)) {
@@ -2543,10 +2553,18 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 #endif
                                }
                                else if (strequal(value_name, SPOOL_REG_SERVERNAME)) {
 #endif
                                }
                                else if (strequal(value_name, SPOOL_REG_SERVERNAME)) {
-                                       push_reg_sz(mem_ctx, &value.data, longname);
+                                       ok = push_reg_sz(mem_ctx, &value.data, longname);
+                                       if (!ok) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
                                }
                                else if (strequal(value_name, SPOOL_REG_SHORTSERVERNAME)) {
                                }
                                else if (strequal(value_name, SPOOL_REG_SHORTSERVERNAME)) {
-                                       push_reg_sz(mem_ctx, &value.data, lp_netbios_name());
+                                       ok = push_reg_sz(mem_ctx, &value.data, lp_netbios_name());
+                                       if (!ok) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
                                }
                                else {
                                        value.type = info[j].type;
                                }
                                else {
                                        value.type = info[j].type;