s3-spoolss: add some printer info validation for AddPrinter calls.
authorGünther Deschner <gd@samba.org>
Tue, 14 Jul 2009 12:34:30 +0000 (14:34 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 18 Feb 2010 01:19:33 +0000 (02:19 +0100)
Guenther

source3/rpc_server/srv_spoolss_nt.c

index 34daf40d8f9548752d0d455ac6a6143ec6d1668f..66eb59bd40f582cb57c346dfb0bcb09cec234838 100644 (file)
@@ -7145,6 +7145,28 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
                return WERR_PRINTER_ALREADY_EXISTS;
        }
 
+       /* validate printer info struct */
+       if (!info_ctr->info.info2->printername ||
+           strlen(info_ctr->info.info2->printername) == 0) {
+               free_a_printer(&printer,2);
+               return WERR_INVALID_PRINTER_NAME;
+       }
+       if (!info_ctr->info.info2->portname ||
+           strlen(info_ctr->info.info2->portname) == 0) {
+               free_a_printer(&printer,2);
+               return WERR_UNKNOWN_PORT;
+       }
+       if (!info_ctr->info.info2->drivername ||
+           strlen(info_ctr->info.info2->drivername) == 0) {
+               free_a_printer(&printer,2);
+               return WERR_UNKNOWN_PRINTER_DRIVER;
+       }
+       if (!info_ctr->info.info2->printprocessor ||
+           strlen(info_ctr->info.info2->printprocessor) == 0) {
+               free_a_printer(&printer,2);
+               return WERR_UNKNOWN_PRINTPROCESSOR;
+       }
+
        /* FIXME!!!  smbd should check to see if the driver is installed before
           trying to add a printer like this  --jerry */