diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-20 19:06:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:18:52 -0500 |
commit | f014291edda9449c73757063fc306d564445cc18 (patch) | |
tree | 8742ef705a0d2a5eb2a3b0483a56d446c6becff0 | |
parent | a167c2c09eb1e3cc9a9f22974d726fcdb6ee218d (diff) | |
download | samba-f014291edda9449c73757063fc306d564445cc18.tar.gz samba-f014291edda9449c73757063fc306d564445cc18.tar.bz2 samba-f014291edda9449c73757063fc306d564445cc18.zip |
r16424: Fix possible null deref and a memory leak found by
examining Klockwork #1519. get_printer_subkeys()
could return zero without initializing it's return
pointer arg. Fixed this. Added free of subkey pointer
return in registry/reg_printing.c (interesting that
neithe Coverity or Klocwork found this one).
Jeremy.
(This used to be commit 4fbeae1a3ac3499e5d9f566655cbafccd9d691cb)
-rw-r--r-- | source3/printing/nt_printing.c | 2 | ||||
-rw-r--r-- | source3/registry/reg_printing.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 6a7fd4d398..5c4039722e 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -2767,6 +2767,8 @@ int get_printer_subkeys( NT_PRINTER_DATA *data, const char* key, fstring **subke fstring *subkeys_ptr = NULL; fstring subkeyname; + *subkeys = NULL; + if ( !data ) return 0; diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index f001fdad24..a712a7c970 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -346,8 +346,10 @@ static BOOL key_printers_store_keys( const char *key, REGSUBKEY_CTR *subkeys ) if ( lookup_printerkey(printer->info_2->data, subkeyname) == -1 ) { DEBUG(5,("key_printers_store_keys: adding key %s\n", existing_subkeys[i])); - if ( add_new_printer_key( printer->info_2->data, subkeyname ) == -1 ) + if ( add_new_printer_key( printer->info_2->data, subkeyname ) == -1 ) { + SAFE_FREE( existing_subkeys ); return False; + } } } @@ -360,6 +362,8 @@ static BOOL key_printers_store_keys( const char *key, REGSUBKEY_CTR *subkeys ) if ( printer ) free_a_printer( &printer, 2 ); + SAFE_FREE( existing_subkeys ); + return True; } |