[PATCH] Add support for APD_COPY_FROM_DIRECTORY in AddPrinterDriverEx()

Jeremy Allison jra at samba.org
Wed Nov 16 23:28:08 UTC 2016


On Wed, Nov 16, 2016 at 08:38:33AM +0100, Andreas Schneider wrote:
> 
> Review and push appreciated.

In the first patch you have:

+               q = strrchr_m(path, '\\');
+               if (q == NULL) {
+                       return WERR_INVALID_PARAMETER;
+               }
+               *q = '\0';
+
+               do {
+                       q--;
+               } while (*q != '\\' && q != '\0' && q != path);
+
+               if (*q != '\\') {
+                       /* Windows returns 0x00000bcb */
+                       return WERR_INVALID_PARAMETER;
+               }
+
+               *driver_directory = q + 1;

So you reverse search for '\\', then truncate,
then reverse search again for '\\'.

Why not just do another strrchr_m ?

Shouldn't this be (with added comments):

+		/* Remove last component. */
+               q = strrchr_m(path, '\\');
+               if (q == NULL) {
+                       return WERR_INVALID_PARAMETER;
+               }
+               *q = '\0';
+
+		/* Find next to last component. */
+		q = strrchr_m(path, '\\');
+
+               if (*q != '\\') {
+                       /* Windows returns 0x00000bcb */
+                       return WERR_INVALID_PARAMETER;
+               }
+
+               *driver_directory = q + 1;

I guess I don't understand exactly what APD_COPY_FROM_DIRECTORY
means. Can you explain in the code exactly what you're trying
to achieve here ?

Jeremy.



More information about the samba-technical mailing list