]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Fixed env variable handling in filterExternalCUPS()
authorTill Kamppeter <till.kamppeter@gmail.com>
Tue, 7 Dec 2021 01:44:45 +0000 (22:44 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Tue, 7 Dec 2021 01:44:45 +0000 (22:44 -0300)
- Do not forward blank environment variables (name is empty string)
  into the environment of he called filter/backend.
- Do not match a given env variable name with a part of an existing
  name (like CUPS_SERVER with CUPS_SERVERBIN). This way CUPS_SERVER in
  the environment of the caller overwrote CUPS_SERVERBIN in the
  environment of the filter to be called.

cupsfilters/filter.c

index 3b9f5e2bca9de74e29ef0f8615cd780185ad1372..5700ea0a8f6d17726ecef8332359a279080cd914 100644 (file)
@@ -712,7 +712,7 @@ add_env_var(char *name,   /* I - Name of environment variable to set */
       name_len;
 
 
-  if (!name || !env)
+  if (!name || !env || !name[0])
     return (-1);
 
   /* Assemble a "VAR=VALUE" string and the string length of "VAR" */
@@ -737,7 +737,7 @@ add_env_var(char *name,   /* I - Name of environment variable to set */
      value if it is there */
   if (*env)
     for (i = 0; (*env)[i]; i ++)
-      if (strncmp((*env)[i], p, name_len) == 0)
+      if (strncmp((*env)[i], p, name_len) == 0 && (*env)[i][name_len] == '=')
       {
        free((*env)[i]);
        (*env)[i] = p;