add a few error checks in EnumPrinterData()
authorGerald Carter <jerry@samba.org>
Mon, 31 Mar 2003 00:59:58 +0000 (00:59 +0000)
committerGerald Carter <jerry@samba.org>
Mon, 31 Mar 2003 00:59:58 +0000 (00:59 +0000)
source/rpc_server/srv_spoolss_nt.c

index a7b73b5ac9dc5fb7bbf4cdb53f9a3b8aa3a1944e..0e81fa38d57f89a87f96c58886f80ea9c8eaf4d1 100644 (file)
@@ -7572,7 +7572,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
        Printer_entry   *Printer = find_printer_index_by_hnd(p, handle);
        int             snum;
        WERROR          result;
-       REGISTRY_VALUE  *val;
+       REGISTRY_VALUE  *val = NULL;
        NT_PRINTER_DATA *p_data;
        int             i, key_index, num_values;
        int             name_length;
@@ -7610,7 +7610,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
         * cf: MSDN EnumPrinterData remark section
         */
         
-       if ( !in_value_len && !in_data_len ) 
+       if ( !in_value_len && !in_data_len && (key_index != -1) 
        {
                DEBUGADD(6,("Activating NT mega-hack to find sizes\n"));
 
@@ -7650,8 +7650,9 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
         * the value len is wrong in NT sp3
         * that's the number of bytes not the number of unicode chars
         */
-        
-       val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx );
+       
+       if ( key_index != -1 )
+               val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx );
 
        if ( !val ) 
        {