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.

andybradford 2014-12-12 06:30 trunk
Commit 6e7cb7f27a190702593a2a54cbe5340453a13d74
2 files changed +1 +2 -1
+1
--- src/http.c
+++ src/http.c
@@ -342,10 +342,11 @@
342342
url_parse(&zLine[i], 0);
343343
fSeenHttpAuth = 0;
344344
if( g.zHttpAuth ) free(g.zHttpAuth);
345345
g.zHttpAuth = get_httpauth();
346346
transport_close(&g.url);
347
+ transport_global_shutdown(&g.url);
347348
return http_exchange(pSend, pReply, useLogin, maxRedirect);
348349
}else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
349350
if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
350351
isCompressed = 0;
351352
}else if( fossil_strnicmp(&zLine[14],
352353
--- 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
--- src/http_socket.c
+++ src/http_socket.c
@@ -45,10 +45,11 @@
4545
** There can only be a single socket connection open at a time.
4646
** State information about that socket is stored in the following
4747
** local variables:
4848
*/
4949
static int socketIsInit = 0; /* True after global initialization */
50
+static int addrIsInit = 0; /* True once addr is initialized */
5051
#if defined(_WIN32)
5152
static WSADATA socketInfo; /* Windows socket initialize data */
5253
#endif
5354
static int iSocket = -1; /* The socket on which we talk to the server */
5455
static char *socketErrMsg = 0; /* Text of most recent socket error */
@@ -105,10 +106,11 @@
105106
WSACleanup();
106107
#endif
107108
socket_clear_errmsg();
108109
socketIsInit = 0;
109110
}
111
+ addrIsInit = 0;
110112
}
111113
112114
/*
113115
** Close the currently open socket. If no socket is open, this routine
114116
** is a no-op.
@@ -133,11 +135,10 @@
133135
**
134136
** Return the number of errors.
135137
*/
136138
int socket_open(UrlData *pUrlData){
137139
static struct sockaddr_in addr; /* The server address */
138
- static int addrIsInit = 0; /* True once addr is initialized */
139140
140141
socket_global_init();
141142
if( !addrIsInit ){
142143
addr.sin_family = AF_INET;
143144
addr.sin_port = htons(pUrlData->port);
144145
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button