From 9a313bbac02a808b3cd7c3d1308919f4acfac874 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 29 Apr 2010 13:27:58 +0200 Subject: s3-lanman: fix api_DosPrintQGetInfo(). Found by torture test. Guenther --- source3/smbd/lanman.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index b44eb4031c..1a5d9e89f3 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -660,6 +660,20 @@ static void fill_printq_info_52(struct spoolss_DriverInfo3 *driver, } +static const char *strip_unc(const char *unc) +{ + char *p; + + if (unc == NULL) { + return NULL; + } + + if ((p = strrchr(unc, '\\')) != NULL) { + return p+1; + } + + return unc; +} static void fill_printq_info(int uLevel, struct pack_desc* desc, @@ -672,12 +686,12 @@ static void fill_printq_info(int uLevel, case 0: case 1: case 2: - PACKS(desc,"B13", printer_info->printername); + PACKS(desc,"B13", strip_unc(printer_info->printername)); break; case 3: case 4: case 5: - PACKS(desc,"z", printer_info->printername); + PACKS(desc,"z", strip_unc(printer_info->printername)); break; case 51: PACKI(desc,"K", printq_spoolss_status(printer_info->status)); @@ -691,7 +705,7 @@ static void fill_printq_info(int uLevel, PACKI(desc,"W",0); /* until time */ PACKS(desc,"z",""); /* pSepFile */ PACKS(desc,"z","lpd"); /* pPrProc */ - PACKS(desc,"z", printer_info->printername); /* pDestinations */ + PACKS(desc,"z", strip_unc(printer_info->printername)); /* pDestinations */ PACKS(desc,"z",""); /* pParms */ if (printer_info->printername == NULL) { PACKS(desc,"z","UNKNOWN PRINTER"); @@ -716,7 +730,7 @@ static void fill_printq_info(int uLevel, Win9X/ME printer comments. */ PACKI(desc,"W", printq_spoolss_status(printer_info->status)); /* fsStatus */ PACKI(desc,(uLevel == 3 ? "W" : "N"),count); /* cJobs */ - PACKS(desc,"z", printer_info->printername); /* pszPrinters */ + PACKS(desc,"z", strip_unc(printer_info->printername)); /* pszPrinters */ PACKS(desc,"z", printer_info->drivername); /* pszDriverName */ PackDriverData(desc); /* pDriverData */ } @@ -841,6 +855,16 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, goto out; } + werr = rpccli_spoolss_getprinter(cli, mem_ctx, + &handle, + 2, + 0, + &printer_info); + if (!W_ERROR_IS_OK(werr)) { + desc.errcode = W_ERROR_V(werr); + goto out; + } + if (uLevel==52) { uint32_t server_major_version; uint32_t server_minor_version; -- cgit