11/*
22 * HTTP routines for HTMLDOC.
33 *
4- * Copyright © 2020-2021 by Michael R Sweet
4+ * Copyright © 2020-2022 by Michael R Sweet
55 * Copyright © 2007-2019 by Apple Inc.
66 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77 *
@@ -2421,6 +2421,7 @@ httpReconnect2(http_t *http, /* I - HTTP connection */
24212421 if (_httpTLSStart (http ) != 0 )
24222422 {
24232423 httpAddrClose (NULL , http -> fd );
2424+ http -> fd = -1 ;
24242425
24252426 return (-1 );
24262427 }
@@ -3555,7 +3556,9 @@ http_add_field(http_t *http, /* I - HTTP connection */
35553556 const char * value , /* I - Value string */
35563557 int append ) /* I - Append value? */
35573558{
3558- char temp [1024 ]; /* Temporary value string */
3559+ char temp [1024 ], /* Temporary value string */
3560+ combined [HTTP_MAX_VALUE ];
3561+ /* Combined value string */
35593562 size_t fieldlen , /* Length of existing value */
35603563 valuelen , /* Length of value string */
35613564 total ; /* Total length of string */
@@ -3630,8 +3633,6 @@ http_add_field(http_t *http, /* I - HTTP connection */
36303633
36313634 if (total < HTTP_MAX_VALUE && field < HTTP_FIELD_ACCEPT_ENCODING )
36323635 {
3633- char combined [HTTP_MAX_VALUE ]; /* Combined value string */
3634-
36353636 /*
36363637 * Copy short values to legacy char arrays (maintained for binary
36373638 * compatibility with CUPS 1.2.x and earlier applications...)
@@ -3652,21 +3653,21 @@ http_add_field(http_t *http, /* I - HTTP connection */
36523653 * Expand the field value...
36533654 */
36543655
3655- char * combined ; /* New value string */
3656+ char * mcombined ; /* New value string */
36563657
36573658 if (http -> fields [field ] == http -> _fields [field ])
36583659 {
3659- if ((combined = malloc (total + 1 )) != NULL )
3660+ if ((mcombined = malloc (total + 1 )) != NULL )
36603661 {
3661- http -> fields [field ] = combined ;
3662- snprintf (combined , total + 1 , "%s, %s" , http -> _fields [field ], value );
3662+ http -> fields [field ] = mcombined ;
3663+ snprintf (mcombined , total + 1 , "%s, %s" , http -> _fields [field ], value );
36633664 }
36643665 }
3665- else if ((combined = realloc (http -> fields [field ], total + 1 )) != NULL )
3666+ else if ((mcombined = realloc (http -> fields [field ], total + 1 )) != NULL )
36663667 {
3667- http -> fields [field ] = combined ;
3668- strlcat (combined , ", " , total + 1 );
3669- strlcat (combined , value , total + 1 );
3668+ http -> fields [field ] = mcombined ;
3669+ strlcat (mcombined , ", " , total + 1 );
3670+ strlcat (mcombined , value , total + 1 );
36703671 }
36713672 }
36723673 else
@@ -4613,6 +4614,7 @@ http_tls_upgrade(http_t *http) /* I - HTTP connection */
46134614 * Restore the HTTP request data...
46144615 */
46154616
4617+ httpClearFields (http );
46164618 memcpy (http -> _fields , myhttp ._fields , sizeof (http -> _fields ));
46174619 memcpy (http -> fields , myhttp .fields , sizeof (http -> fields ));
46184620
0 commit comments