pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/net/libfetch/files



Module Name:    pkgsrc
Committed By:   wiz
Date:           Tue Feb 18 12:59:54 UTC 2025

Modified Files:
        pkgsrc/net/libfetch/files: http.c

Log Message:
libfetch: Fix proxy connections.

>From Jonathan Perkin <jperkin%smartos.org@localhost>
via drecklypkg commit $e6083c3a737b5451887c0c803b807c63e63aa046


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 pkgsrc/net/libfetch/files/http.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/net/libfetch/files/http.c
diff -u pkgsrc/net/libfetch/files/http.c:1.42 pkgsrc/net/libfetch/files/http.c:1.43
--- pkgsrc/net/libfetch/files/http.c:1.42       Tue Aug 23 17:48:53 2022
+++ pkgsrc/net/libfetch/files/http.c    Tue Feb 18 12:59:54 2025
@@ -1,4 +1,4 @@
-/*     $NetBSD: http.c,v 1.42 2022/08/23 17:48:53 wiz Exp $    */
+/*     $NetBSD: http.c,v 1.43 2025/02/18 12:59:54 wiz Exp $    */
 /*-
  * Copyright (c) 2000-2004 Dag-Erling Co�dan Sm�rgrav
  * Copyright (c) 2003 Thomas Klausner <wiz%NetBSD.org@localhost>
@@ -493,6 +493,16 @@ http_match(const char *str, const char *
        return (hdr);
 }
 
+/* Remove whitespace at the end of the buffer */
+static void
+http_conn_trimright(conn_t *conn)
+{
+       while (conn->buflen &&
+           isspace((unsigned char)conn->buf[conn->buflen - 1]))
+               conn->buflen--;
+       conn->buf[conn->buflen] = '\0';
+}
+
 /*
  * Get the next header and return the appropriate symbolic code.
  */
@@ -501,13 +511,20 @@ http_next_header(conn_t *conn, const cha
 {
        int i;
 
-       if (fetch_getln(conn) == -1)
-               return (hdr_syserror);
-       while (conn->buflen && isspace((unsigned char)conn->buf[conn->buflen - 1]))
-               conn->buflen--;
-       conn->buf[conn->buflen] = '\0';
+       /*
+        * Have to do the stripping here because of the first line. So
+        * it's done twice for the subsequent lines. No big deal
+        */
+       http_conn_trimright(conn);
+
        if (conn->buflen == 0)
                return (hdr_end);
+
+       if (fetch_getln(conn) == -1)
+               return (hdr_syserror);
+
+       http_conn_trimright(conn);
+
        /*
         * We could check for malformed headers but we don't really care.
         * A valid header starts with a token immediately followed by a
@@ -780,7 +797,7 @@ http_connect(struct url *URL, struct url
                        default:
                                /* ignore */ ;
                        }
-               } while (h < hdr_end);
+               } while (h > hdr_end);
        }
        if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 &&
            fetch_ssl(conn, URL, verbose) == -1) {



Home | Main Index | Thread Index | Old Index