s3-spoolss: fix set_printer_hnd_name() to match torture test.
authorGünther Deschner <gd@samba.org>
Sat, 2 Oct 2010 20:14:37 +0000 (22:14 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 11 Oct 2010 14:31:06 +0000 (14:31 +0000)
Guenther

source3/rpc_server/srv_spoolss_nt.c

index c05ba66e427d354f11bf51e079fca1f68acc550e..e63c63e1c553e20c71aa5e6019a699984c69071e 100644 (file)
@@ -586,16 +586,22 @@ static bool set_printer_hnd_name(TALLOC_CTX *mem_ctx,
 
        DEBUGADD(5, ("searching for [%s]\n", aprinter));
 
-       if ((p = strchr(aprinter, ',')) != NULL) {
-               if (*p == ' ')
+       p = strchr(aprinter, ',');
+       if (p != NULL) {
+               char *p2 = p;
+               p++;
+               if (*p == ' ') {
                        p++;
-               if (strnequal(p+1, "DrvConvert", strlen("DrvConvert")) ||
-                   strnequal(p+1, " DrvConvert", strlen(" DrvConvert"))) {
-                       *p = '\0';
-               } else if (strnequal(p+1, "LocalOnly", strlen("LocalOnly")) ||
-                          strnequal(p+1, " LocalOnly", strlen(" LocalOnly"))) {
-                       *p = '\0';
                }
+               if (strncmp(p, "DrvConvert", strlen("DrvConvert")) == 0) {
+                       *p2 = '\0';
+               } else if (strncmp(p, "LocalOnly", strlen("LocalOnly")) == 0) {
+                       *p2 = '\0';
+               }
+       }
+
+       if (p) {
+               DEBUGADD(5, ("stripped handlename: [%s]\n", aprinter));
        }
 
        /* check for the Port Monitor Interface */
@@ -1691,7 +1697,7 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                DEBUG(0,("_spoolss_OpenPrinterEx: Cannot open a printer handle "
                        "for printer %s\n", r->in.printername));
                ZERO_STRUCTP(r->out.handle);
-               return WERR_INVALID_PARAM;
+               return WERR_INVALID_PRINTER_NAME;
        }
 
        Printer = find_printer_index_by_hnd(p, r->out.handle);