Fossil SCM
On 302 redirects, cause addr and socket reinitialize so it has the info for the new location and not the old. This may address a bug reported on the ML by Ashwin Hirschi in which a redirect was causing Fossil to segfault, likely due to redirecting to the same site repeatedly because addr was remaining unchanged.
Commit
6e7cb7f27a190702593a2a54cbe5340453a13d74
Parent
37e234fa8893bb7…
2 files changed
+1
+2
-1
+1
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -342,10 +342,11 @@ | ||
| 342 | 342 | url_parse(&zLine[i], 0); |
| 343 | 343 | fSeenHttpAuth = 0; |
| 344 | 344 | if( g.zHttpAuth ) free(g.zHttpAuth); |
| 345 | 345 | g.zHttpAuth = get_httpauth(); |
| 346 | 346 | transport_close(&g.url); |
| 347 | + transport_global_shutdown(&g.url); | |
| 347 | 348 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 348 | 349 | }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){ |
| 349 | 350 | if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){ |
| 350 | 351 | isCompressed = 0; |
| 351 | 352 | }else if( fossil_strnicmp(&zLine[14], |
| 352 | 353 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -342,10 +342,11 @@ | |
| 342 | url_parse(&zLine[i], 0); |
| 343 | fSeenHttpAuth = 0; |
| 344 | if( g.zHttpAuth ) free(g.zHttpAuth); |
| 345 | g.zHttpAuth = get_httpauth(); |
| 346 | transport_close(&g.url); |
| 347 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 348 | }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){ |
| 349 | if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){ |
| 350 | isCompressed = 0; |
| 351 | }else if( fossil_strnicmp(&zLine[14], |
| 352 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -342,10 +342,11 @@ | |
| 342 | url_parse(&zLine[i], 0); |
| 343 | fSeenHttpAuth = 0; |
| 344 | if( g.zHttpAuth ) free(g.zHttpAuth); |
| 345 | g.zHttpAuth = get_httpauth(); |
| 346 | transport_close(&g.url); |
| 347 | transport_global_shutdown(&g.url); |
| 348 | return http_exchange(pSend, pReply, useLogin, maxRedirect); |
| 349 | }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){ |
| 350 | if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){ |
| 351 | isCompressed = 0; |
| 352 | }else if( fossil_strnicmp(&zLine[14], |
| 353 |
+2
-1
| --- src/http_socket.c | ||
| +++ src/http_socket.c | ||
| @@ -45,10 +45,11 @@ | ||
| 45 | 45 | ** There can only be a single socket connection open at a time. |
| 46 | 46 | ** State information about that socket is stored in the following |
| 47 | 47 | ** local variables: |
| 48 | 48 | */ |
| 49 | 49 | static int socketIsInit = 0; /* True after global initialization */ |
| 50 | +static int addrIsInit = 0; /* True once addr is initialized */ | |
| 50 | 51 | #if defined(_WIN32) |
| 51 | 52 | static WSADATA socketInfo; /* Windows socket initialize data */ |
| 52 | 53 | #endif |
| 53 | 54 | static int iSocket = -1; /* The socket on which we talk to the server */ |
| 54 | 55 | static char *socketErrMsg = 0; /* Text of most recent socket error */ |
| @@ -105,10 +106,11 @@ | ||
| 105 | 106 | WSACleanup(); |
| 106 | 107 | #endif |
| 107 | 108 | socket_clear_errmsg(); |
| 108 | 109 | socketIsInit = 0; |
| 109 | 110 | } |
| 111 | + addrIsInit = 0; | |
| 110 | 112 | } |
| 111 | 113 | |
| 112 | 114 | /* |
| 113 | 115 | ** Close the currently open socket. If no socket is open, this routine |
| 114 | 116 | ** is a no-op. |
| @@ -133,11 +135,10 @@ | ||
| 133 | 135 | ** |
| 134 | 136 | ** Return the number of errors. |
| 135 | 137 | */ |
| 136 | 138 | int socket_open(UrlData *pUrlData){ |
| 137 | 139 | static struct sockaddr_in addr; /* The server address */ |
| 138 | - static int addrIsInit = 0; /* True once addr is initialized */ | |
| 139 | 140 | |
| 140 | 141 | socket_global_init(); |
| 141 | 142 | if( !addrIsInit ){ |
| 142 | 143 | addr.sin_family = AF_INET; |
| 143 | 144 | addr.sin_port = htons(pUrlData->port); |
| 144 | 145 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -45,10 +45,11 @@ | |
| 45 | ** There can only be a single socket connection open at a time. |
| 46 | ** State information about that socket is stored in the following |
| 47 | ** local variables: |
| 48 | */ |
| 49 | static int socketIsInit = 0; /* True after global initialization */ |
| 50 | #if defined(_WIN32) |
| 51 | static WSADATA socketInfo; /* Windows socket initialize data */ |
| 52 | #endif |
| 53 | static int iSocket = -1; /* The socket on which we talk to the server */ |
| 54 | static char *socketErrMsg = 0; /* Text of most recent socket error */ |
| @@ -105,10 +106,11 @@ | |
| 105 | WSACleanup(); |
| 106 | #endif |
| 107 | socket_clear_errmsg(); |
| 108 | socketIsInit = 0; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | ** Close the currently open socket. If no socket is open, this routine |
| 114 | ** is a no-op. |
| @@ -133,11 +135,10 @@ | |
| 133 | ** |
| 134 | ** Return the number of errors. |
| 135 | */ |
| 136 | int socket_open(UrlData *pUrlData){ |
| 137 | static struct sockaddr_in addr; /* The server address */ |
| 138 | static int addrIsInit = 0; /* True once addr is initialized */ |
| 139 | |
| 140 | socket_global_init(); |
| 141 | if( !addrIsInit ){ |
| 142 | addr.sin_family = AF_INET; |
| 143 | addr.sin_port = htons(pUrlData->port); |
| 144 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -45,10 +45,11 @@ | |
| 45 | ** There can only be a single socket connection open at a time. |
| 46 | ** State information about that socket is stored in the following |
| 47 | ** local variables: |
| 48 | */ |
| 49 | static int socketIsInit = 0; /* True after global initialization */ |
| 50 | static int addrIsInit = 0; /* True once addr is initialized */ |
| 51 | #if defined(_WIN32) |
| 52 | static WSADATA socketInfo; /* Windows socket initialize data */ |
| 53 | #endif |
| 54 | static int iSocket = -1; /* The socket on which we talk to the server */ |
| 55 | static char *socketErrMsg = 0; /* Text of most recent socket error */ |
| @@ -105,10 +106,11 @@ | |
| 106 | WSACleanup(); |
| 107 | #endif |
| 108 | socket_clear_errmsg(); |
| 109 | socketIsInit = 0; |
| 110 | } |
| 111 | addrIsInit = 0; |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | ** Close the currently open socket. If no socket is open, this routine |
| 116 | ** is a no-op. |
| @@ -133,11 +135,10 @@ | |
| 135 | ** |
| 136 | ** Return the number of errors. |
| 137 | */ |
| 138 | int socket_open(UrlData *pUrlData){ |
| 139 | static struct sockaddr_in addr; /* The server address */ |
| 140 | |
| 141 | socket_global_init(); |
| 142 | if( !addrIsInit ){ |
| 143 | addr.sin_family = AF_INET; |
| 144 | addr.sin_port = htons(pUrlData->port); |
| 145 |