@@ -241,6 +241,7 @@ http_fillbuf(struct httpio *io, size_t len)
241241 if (io -> chunksize == 0 ) {
242242 switch (http_new_chunk (io )) {
243243 case -1 :
244+ http_seterr (HTTP_PROTOCOL_ERROR );;
244245 io -> error = EPROTO ;
245246 return (-1 );
246247 case 0 :
@@ -492,26 +493,25 @@ http_get_reply(conn_t *conn, int *keep_alive)
492493 p = conn -> buf + 4 ;
493494 if (* p == '/' ) {
494495 if (p [1 ] != '1' || p [2 ] != '.' )
495- return ( HTTP_PROTOCOL_ERROR ) ;
496+ goto ouch ;
496497 if (p [3 ] == '1' ) {
497498 if (keep_alive )
498499 * keep_alive = 1 ;
499500 } else if (p [3 ] != '0' )
500- return (HTTP_PROTOCOL_ERROR );
501- /* HTTP/1.1 defaults to the use of "persistent connections" */
502- if (keep_alive && p [3 ] == '1' ) {
503- * keep_alive = 1 ;
504- }
501+ goto ouch ;
505502 p += 4 ;
506503 }
507504 if (* p != ' ' ||
508505 !isdigit ((unsigned char )p [1 ]) ||
509506 !isdigit ((unsigned char )p [2 ]) ||
510507 !isdigit ((unsigned char )p [3 ]))
511- return ( HTTP_PROTOCOL_ERROR ) ;
508+ goto ouch ;
512509
513510 conn -> err = (p [1 ] - '0' ) * 100 + (p [2 ] - '0' ) * 10 + (p [3 ] - '0' );
514511 return (conn -> err );
512+ ouch :
513+ conn -> err = HTTP_PROTOCOL_ERROR ;
514+ return (HTTP_PROTOCOL_ERROR );
515515}
516516
517517/*
@@ -1541,7 +1541,7 @@ http_get_proxy(struct url * url, const char *flags)
15411541 if (((p = getenv ("HTTP_PROXY" )) || (p = getenv ("http_proxy" ))) &&
15421542 * p && (purl = fetchParseURL (p ))) {
15431543 if (!* purl -> scheme )
1544- strcpy (purl -> scheme , SCHEME_HTTP );
1544+ strlcpy (purl -> scheme , SCHEME_HTTP , sizeof ( purl -> scheme ) );
15451545 if (!purl -> port )
15461546 purl -> port = fetch_default_proxy_port (purl -> scheme );
15471547 if (strcmp (purl -> scheme , SCHEME_HTTP ) == 0 )
@@ -1855,7 +1855,8 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us,
18551855 */
18561856 break ;
18571857 case HTTP_PROTOCOL_ERROR :
1858- /* fall through */
1858+ http_seterr (conn -> err );
1859+ goto ouch ;
18591860 case -1 :
18601861 fetch_syserr ();
18611862 goto ouch ;
@@ -1930,8 +1931,8 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us,
19301931 /* Only copy credentials if the host matches */
19311932 if (strcmp (new -> host , url -> host ) == 0 &&
19321933 !* new -> user && !* new -> pwd ) {
1933- strcpy (new -> user , url -> user );
1934- strcpy (new -> pwd , url -> pwd );
1934+ strlcpy (new -> user , url -> user , sizeof ( new -> user ) );
1935+ strlcpy (new -> pwd , url -> pwd , sizeof ( new -> pwd ) );
19351936 }
19361937 new -> offset = url -> offset ;
19371938 new -> length = url -> length ;
0 commit comments