r11073: safety checks on pointers to prevent crashing when converting REG_MULTI_SZ
authorGerald Carter <jerry@samba.org>
Fri, 14 Oct 2005 21:46:32 +0000 (21:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:05:00 +0000 (11:05 -0500)
(This used to be commit db8d85aa1ec5c486f061f97627b6b18a0e17cd34)

source3/registry/reg_util.c

index 4338699c00e6637483e4ec0e8f4dd8f97fd57010..511e9b43354537ce5ee02d05cd8d894b5d8ab1d2 100644 (file)
@@ -137,7 +137,10 @@ int regval_convert_multi_sz( uint16 *multi_string, size_t multi_len, char ***val
        uint16 *wp;
        
        *values = NULL;
-       
+
+       if ( !multi_string || !*values )
+               return 0;
+
        /* just count the NULLs */
        
        for ( i=0; (i<multi_len-1) && !(multi_string[i]==0x0 && multi_string[i+1]==0x0); i++ ) {
@@ -183,6 +186,9 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
        size_t buf_size = 0;
        uint16 *buf, *b;
        UNISTR2 sz;
+
+       if ( !values || !*buffer )
+               return 0;
        
        /* go ahead and alloc some space */