Blame SOURCES/0001-Multiple-security-disclosure-issues.patch

50ac8c
diff --git a/cups/http-private.h b/cups/http-private.h
50ac8c
index f2640f1..b7f9b6e 100644
50ac8c
--- a/cups/http-private.h
50ac8c
+++ b/cups/http-private.h
50ac8c
@@ -380,6 +380,7 @@ extern const char	*_httpResolveURI(const char *uri, char *resolved_uri,
50ac8c
 					 int (*cb)(void *context),
50ac8c
 					 void *context);
50ac8c
 extern int		_httpUpdate(http_t *http, http_status_t *status);
50ac8c
+extern size_t           _httpTLSPending(http_t *http);
50ac8c
 extern int		_httpWait(http_t *http, int msec, int usessl);
50ac8c
 
50ac8c
 extern void		_httpTLSSetOptions(int options);
50ac8c
diff --git a/cups/http.c b/cups/http.c
50ac8c
index e02b66d..128a52a 100644
50ac8c
--- a/cups/http.c
50ac8c
+++ b/cups/http.c
50ac8c
@@ -1817,7 +1817,7 @@ httpPrintf(http_t     *http,		/* I - Connection to server */
50ac8c
 	   ...)				/* I - Additional args as needed */
50ac8c
 {
50ac8c
   int		bytes;			/* Number of bytes to write */
50ac8c
-  char		buf[16384];		/* Buffer for formatted string */
50ac8c
+  char		buf[65536];		/* Buffer for formatted string */
50ac8c
   va_list	ap;			/* Variable argument pointer */
50ac8c
 
50ac8c
 
50ac8c
@@ -1829,7 +1829,12 @@ httpPrintf(http_t     *http,		/* I - Connection to server */
50ac8c
 
50ac8c
   DEBUG_printf(("3httpPrintf: %s", buf));
50ac8c
 
50ac8c
-  if (http->data_encoding == HTTP_ENCODE_FIELDS)
50ac8c
+  if (bytes > (ssize_t)(sizeof(buf) - 1))
50ac8c
+  {
50ac8c
+    http->error = ENOMEM;
50ac8c
+    return (-1);
50ac8c
+  }
50ac8c
+  else if (http->data_encoding == HTTP_ENCODE_FIELDS)
50ac8c
     return (httpWrite2(http, buf, bytes));
50ac8c
   else
50ac8c
   {
50ac8c
diff --git a/cups/ipp.c b/cups/ipp.c
50ac8c
index 0384792..2b613d7 100644
50ac8c
--- a/cups/ipp.c
50ac8c
+++ b/cups/ipp.c
50ac8c
@@ -3847,9 +3847,7 @@ ippSetValueTag(
50ac8c
         break;
50ac8c
 
50ac8c
     case IPP_TAG_NAME :
50ac8c
-        if (temp_tag != IPP_TAG_KEYWORD && temp_tag != IPP_TAG_URI &&
50ac8c
-            temp_tag != IPP_TAG_URISCHEME && temp_tag != IPP_TAG_LANGUAGE &&
50ac8c
-            temp_tag != IPP_TAG_MIMETYPE)
50ac8c
+        if (temp_tag != IPP_TAG_KEYWORD)
50ac8c
           return (0);
50ac8c
 
50ac8c
         (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_COPY));
50ac8c
@@ -3857,10 +3855,7 @@ ippSetValueTag(
50ac8c
 
50ac8c
     case IPP_TAG_NAMELANG :
50ac8c
     case IPP_TAG_TEXTLANG :
50ac8c
-        if (value_tag == IPP_TAG_NAMELANG &&
50ac8c
-            (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD &&
50ac8c
-             temp_tag != IPP_TAG_URI && temp_tag != IPP_TAG_URISCHEME &&
50ac8c
-             temp_tag != IPP_TAG_LANGUAGE && temp_tag != IPP_TAG_MIMETYPE))
50ac8c
+        if (value_tag == IPP_TAG_NAMELANG && (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD))
50ac8c
           return (0);
50ac8c
 
50ac8c
         if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
50ac8c
diff --git a/cups/snmp.c b/cups/snmp.c
50ac8c
index 0c0e520..ff4fcd4 100644
50ac8c
--- a/cups/snmp.c
50ac8c
+++ b/cups/snmp.c
50ac8c
@@ -1279,6 +1279,9 @@ asn1_get_integer(
50ac8c
   int	value;				/* Integer value */
50ac8c
 
50ac8c
 
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (0);
50ac8c
+
50ac8c
   if (length > sizeof(int))
50ac8c
   {
50ac8c
     (*buffer) += length;
50ac8c
@@ -1305,6 +1308,9 @@ asn1_get_length(unsigned char **buffer,	/* IO - Pointer in buffer */
50ac8c
   unsigned	length;			/* Length */
50ac8c
 
50ac8c
 
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (0);
50ac8c
+
50ac8c
   length = **buffer;
50ac8c
   (*buffer) ++;
50ac8c
 
50ac8c
@@ -1347,6 +1353,9 @@ asn1_get_oid(
50ac8c
   int		number;			/* OID number */
50ac8c
 
50ac8c
 
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (0);
50ac8c
+
50ac8c
   valend = *buffer + length;
50ac8c
   oidptr = oid;
50ac8c
   oidend = oid + oidsize - 1;
50ac8c
@@ -1395,9 +1404,12 @@ asn1_get_packed(
50ac8c
   int	value;				/* Value */
50ac8c
 
50ac8c
 
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (0);
50ac8c
+
50ac8c
   value = 0;
50ac8c
 
50ac8c
-  while ((**buffer & 128) && *buffer < bufend)
50ac8c
+  while (*buffer < bufend && (**buffer & 128))
50ac8c
   {
50ac8c
     value = (value << 7) | (**buffer & 127);
50ac8c
     (*buffer) ++;
50ac8c
@@ -1425,6 +1437,9 @@ asn1_get_string(
50ac8c
     char          *string,		/* I  - String buffer */
50ac8c
     int           strsize)		/* I  - String buffer size */
50ac8c
 {
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (NULL);
50ac8c
+
50ac8c
   if (length > (bufend - *buffer))
50ac8c
     length = bufend - *buffer;
50ac8c
 
50ac8c
@@ -1475,6 +1490,9 @@ asn1_get_type(unsigned char **buffer,	/* IO - Pointer in buffer */
50ac8c
   int	type;				/* Type */
50ac8c
 
50ac8c
 
50ac8c
+  if (*buffer >= bufend)
50ac8c
+    return (0);
50ac8c
+
50ac8c
   type = **buffer;
50ac8c
   (*buffer) ++;
50ac8c
 
50ac8c
diff --git a/scheduler/client.c b/scheduler/client.c
50ac8c
index 6e2f7e6..e20344d 100644
50ac8c
--- a/scheduler/client.c
50ac8c
+++ b/scheduler/client.c
50ac8c
@@ -770,6 +770,23 @@ cupsdReadClient(cupsd_client_t *con)	/* I - Client to read from */
50ac8c
 		  con->request ? ipp_states[con->request->state] : "",
50ac8c
 		  con->file);
50ac8c
 
50ac8c
+  if (con->http.error == EPIPE &&
50ac8c
+      (con->http.used == 0
50ac8c
+#ifdef HAVE_SSL
50ac8c
+        || _httpTLSPending(&(con->http)) == 0
50ac8c
+#endif /* HAVE_SSL */
50ac8c
+      ) && recv(con->http.fd, buf, 1, MSG_PEEK) < 1)
50ac8c
+  {
50ac8c
+   /*
50ac8c
+    * Connection closed...
50ac8c
+    */
50ac8c
+
50ac8c
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Closing on EOF.", con->http.fd);
50ac8c
+    cupsdCloseClient(con);
50ac8c
+    return;
50ac8c
+  }
50ac8c
+
50ac8c
+
50ac8c
 #ifdef HAVE_SSL
50ac8c
   if (con->auto_ssl)
50ac8c
   {
50ac8c
diff --git a/scheduler/tls-openssl.c b/scheduler/tls-openssl.c
50ac8c
index 759f393..a7a8e85 100644
50ac8c
--- a/scheduler/tls-openssl.c
50ac8c
+++ b/scheduler/tls-openssl.c
50ac8c
@@ -144,6 +144,17 @@ cupsdStartTLS(cupsd_client_t *con)	/* I - Client connection */
50ac8c
 }
50ac8c
 
50ac8c
 
50ac8c
+/*
50ac8c
+ * '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
50ac8c
+ */
50ac8c
+
50ac8c
+size_t                                  /* O - Bytes available */
50ac8c
+_httpTLSPending(http_t *http)           /* I - HTTP connection */
50ac8c
+{
50ac8c
+  return (SSL_pending(http->tls));
50ac8c
+}
50ac8c
+
50ac8c
+
50ac8c
 /*
50ac8c
  * 'make_certificate()' - Make a self-signed SSL/TLS certificate.
50ac8c
  */