]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
cgi-bin/admin.c: Prevent accessing ppd_name if ppd_name is NULL
authorZdenek Dohnal <zdohnal@redhat.com>
Wed, 8 Sep 2021 06:04:13 +0000 (08:04 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Wed, 8 Sep 2021 06:04:13 +0000 (08:04 +0200)
The fix provided by Alfonso Gregory, fixes regression after PR #218.

cgi-bin/admin.c

index ff944b69a6cee22772562dd16d0ddabbc2bb1307..294f5cb4945dc25a082e6779d191452e4b06542a 100644 (file)
@@ -1218,17 +1218,7 @@ do_am_printer(http_t *http,              /* I - HTTP connection */
 
       cgiCopyTemplateLang("printer-modified.tmpl");
     }
-    else if (strcmp(ppd_name, "everywhere") && !strstr(ppd_name, "driverless"))
-    {
-      /*
-       * If we don't have an everywhere model, show printer-added
-       * template with warning about drivers going away...
-       */
-
-      cgiStartHTML(title);
-      cgiCopyTemplateLang("printer-added.tmpl");
-    }
-    else
+    else if (ppd_name && (strcmp(ppd_name, "everywhere") == 0 || strstr(ppd_name, "driverless")))
     {
      /*
       * Set the printer options...
@@ -1238,6 +1228,16 @@ do_am_printer(http_t *http,              /* I - HTTP connection */
       do_set_options(http, 0);
       return;
     }
+    else
+    {
+     /*
+      * If we don't have an everywhere model, show printer-added
+      * template with warning about drivers going away...
+      */
+
+      cgiStartHTML(title);
+      cgiCopyTemplateLang("printer-added.tmpl");
+    }
 
     cgiEndHTML();
   }