]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cgi-bin/var.c
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / cgi-bin / var.c
index 90ab8bb526125d379a6c677d4140c52d0dc1305c..c50833cbd85701bdda0db691c2fec752f7d9cfbd 100644 (file)
@@ -1,16 +1,14 @@
 /*
- * "$Id$"
- *
  * CGI form variable and array functions for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2005 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
@@ -437,9 +435,9 @@ cgiSetCookie(const char *name,              /* I - Name */
     printf(" expires=%s;", httpGetDateString2(expires, date, sizeof(date)));
   }
   if (secure)
-    puts(" secure;");
+    puts(" httponly; secure;");
   else
-    putchar('\n');
+    puts(" httponly;");
 }
 
 
@@ -626,6 +624,8 @@ cgi_initialize_cookies(void)
 
   while (*cookie)
   {
+    int        skip = 0;                       /* Skip this cookie? */
+
    /*
     * Skip leading whitespace...
     */
@@ -641,9 +641,14 @@ cgi_initialize_cookies(void)
 
     for (ptr = name; *cookie && *cookie != '=';)
       if (ptr < (name + sizeof(name) - 1))
+      {
         *ptr++ = *cookie++;
+      }
       else
-        break;
+      {
+        skip = 1;
+       cookie ++;
+      }
 
     if (*cookie != '=')
       break;
@@ -659,26 +664,38 @@ cgi_initialize_cookies(void)
     {
       for (cookie ++, ptr = value; *cookie && *cookie != '\"';)
         if (ptr < (value + sizeof(value) - 1))
+       {
          *ptr++ = *cookie++;
+       }
        else
-         break;
+       {
+         skip = 1;
+         cookie ++;
+       }
 
       if (*cookie == '\"')
         cookie ++;
+      else
+        skip = 1;
     }
     else
     {
       for (ptr = value; *cookie && *cookie != ';';)
         if (ptr < (value + sizeof(value) - 1))
+       {
          *ptr++ = *cookie++;
+       }
        else
-         break;
+       {
+         skip = 1;
+         cookie ++;
+       }
     }
 
     if (*cookie == ';')
       cookie ++;
     else if (*cookie)
-      break;
+      skip = 1;
 
     *ptr = '\0';
 
@@ -687,7 +704,7 @@ cgi_initialize_cookies(void)
     * "$"...
     */
 
-    if (name[0] != '$')
+    if (name[0] != '$' && !skip)
       num_cookies = cupsAddOption(name, value, num_cookies, &cookies);
   }
 }
@@ -821,7 +838,7 @@ cgi_initialize_multipart(
            */
 
            write(fd, line, 8192);
-           memmove(line, line + 8192, ptr - line - 8192);
+           memmove(line, line + 8192, (size_t)(ptr - line - 8192));
            ptr -= 8192;
          }
        }
@@ -1275,8 +1292,3 @@ cgi_unlink_file(void)
     form_file = NULL;
   }
 }
-
-
-/*
- * End of "$Id$".
- */