Author: tpot
Date: 2005-02-25 05:39:01 +0000 (Fri, 25 Feb 2005)
New Revision: 5552

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5552

Log:
Don't try to read the value of r.out.result when the dcerpc client
function returns non-OK.  If a non-OK status is returned then some or
all or r.out is likely to be uninitialised.

Modified:
   branches/SAMBA_4_0/source/torture/rpc/spoolss.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/rpc/spoolss.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/spoolss.c     2005-02-25 05:25:17 UTC 
(rev 5551)
+++ branches/SAMBA_4_0/source/torture/rpc/spoolss.c     2005-02-25 05:39:01 UTC 
(rev 5552)
@@ -55,13 +55,18 @@
                        status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r);
                }
                
-               if (!NT_STATUS_IS_OK(status) ||
-                   !W_ERROR_IS_OK(r.out.result)) {
-                       printf("GetPrinter failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("GetPrinter failed - %s\n", nt_errstr(status));
                        ret = False;
                        continue;
                }
+               
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("GetPrinter failed - %s\n", 
+                              win_errstr(r.out.result));
+                       ret = False;
+                       continue;
+               }
        }
 
        return ret;
@@ -174,12 +179,16 @@
                }
        }
 
-       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-               printf("EnumForms failed - %s/%s\n", 
-                      nt_errstr(status), win_errstr(r.out.result));
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("EnumForms failed - %s\n", nt_errstr(status));
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("EnumForms failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
        return True;
 }
 
@@ -195,12 +204,16 @@
 
        status = dcerpc_spoolss_DeleteForm(p, mem_ctx, &r);
 
-       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-               printf("DeleteForm failed - %s/%s\n", 
-                      nt_errstr(status), win_errstr(r.out.result));
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("DeleteForm failed - %s\n", nt_errstr(status));
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("DeleteForm failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
        return True;
 }
 
@@ -248,12 +261,18 @@
 
                status = dcerpc_spoolss_SetForm(p, mem_ctx, &sf);
 
-               if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-                       printf("SetForm failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("SetForm failed - %s\n", nt_errstr(status));
                        ret = False;
-                       /* Fall through to delete */
+                       goto done;
                }
+
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("SetForm failed - %s\n", 
+                              win_errstr(r.out.result));
+                       ret = False;
+                       goto done;
+               }
        }
 
  done:
@@ -454,11 +473,17 @@
 
                status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r);
 
-               if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-                       printf("GetPrinterData failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("GetPrinterData failed - %s\n", 
+                              nt_errstr(status));
                        return False;
                }
+
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("GetPrinterData failed - %s\n", 
+                              win_errstr(r.out.result));
+                       return False;
+               }
        }
 
        return True;
@@ -496,11 +521,17 @@
 
                status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r);
 
-               if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-                       printf("GetPrinterDataEx failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("GetPrinterDataEx failed - %s\n", 
+                              nt_errstr(status));
                        return False;
                }
+
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("GetPrinterDataEx failed - %s\n", 
+                              win_errstr(r.out.result));
+                       return False;
+               }
        }
 
        return True;
@@ -743,12 +774,17 @@
        printf("\nTesting OpenPrinter(%s)\n", r.in.printername);
 
        status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &r);
-       if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-               printf("OpenPrinter failed - %s/%s\n", 
-                      nt_errstr(status), win_errstr(r.out.result));
+
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("OpenPrinter failed - %s\n", nt_errstr(status));
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("OpenPrinter failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
        if (!test_GetPrinter(p, mem_ctx, &handle)) {
                ret = False;
        }
@@ -893,13 +929,18 @@
                        status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r);
                }
 
-               if (!NT_STATUS_IS_OK(status) ||
-                   !W_ERROR_IS_OK(r.out.result)) {
-                       printf("EnumPrinters failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("EnumPrinters failed - %s\n", 
+                              nt_errstr(status));
                        continue;
                }
 
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("EnumPrinters failed - %s\n", 
+                              win_errstr(r.out.result));
+                       continue;
+               }
+
                if (!r.out.info) {
                        printf("No printers returned");
                        continue;
@@ -957,13 +998,18 @@
                status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r);
        }
                
-       if (!NT_STATUS_IS_OK(status) ||
-           !W_ERROR_IS_OK(r.out.result)) {
-               printf("GetPrinterDriver2 failed - %s/%s\n", 
-                      nt_errstr(status), win_errstr(r.out.result));
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("GetPrinterDriver2 failed - %s\n", 
+                      nt_errstr(status));
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("GetPrinterDriver2 failed - %s\n", 
+                      win_errstr(r.out.result));
+               return False;
+       }
+
        return True;
 }
 #endif
@@ -1007,14 +1053,20 @@
                        status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, 
&r);
                }
                
-               if (!NT_STATUS_IS_OK(status) ||
-                   !W_ERROR_IS_OK(r.out.result)) {
-                       printf("EnumPrinterDrivers failed - %s/%s\n", 
-                              nt_errstr(status), win_errstr(r.out.result));
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("EnumPrinterDrivers failed - %s\n", 
+                              nt_errstr(status));
                        ret = False;
                        break;
                }
 
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       printf("EnumPrinterDrivers failed - %s\n", 
+                              win_errstr(r.out.result));
+                       ret = False;
+                       break;
+               }
+
                if (!r.out.info) {
                        printf("No printer drivers returned");
                        break;

Reply via email to