mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Bug 1021: initialize version in http_got_header
gcc-4.3 -O2 was complaining that http_got_header may use uninitialized
version.major and version.minor. That indeed happened with HTTP/0.9
servers, and the PRE_HTTP_1_1(version) check then had an undefined
result, so http->close could remain 0 even though it should have
become 1; fortunately, it was then set to 1 anyway, because there was
no Content-Length header. The undefined version was also saved in
http->recv_version, but it appears nothing ever reads that. So in the
end, the bug did not cause any symptoms at runtime, but the warning
broke the build on gcc-4.3 if ELinks was configured with --enable-debug.
(cherry picked from commit 5c0128d82d
)
This commit is contained in:
parent
19e2b5fd83
commit
bced779fdb
@ -1423,7 +1423,7 @@ http_got_header(struct socket *socket, struct read_buffer *rb)
|
||||
#endif
|
||||
unsigned char *d;
|
||||
struct uri *uri = conn->proxied_uri; /* Set to the real uri */
|
||||
struct http_version version;
|
||||
struct http_version version = { 0, 9 };
|
||||
enum connection_state state = (conn->state != S_PROC ? S_GETH : S_PROC);
|
||||
int a, h = 200;
|
||||
int cf;
|
||||
@ -1452,6 +1452,9 @@ again:
|
||||
read_from_socket(conn->socket, rb, state, http_got_header);
|
||||
return;
|
||||
}
|
||||
/* a == -2 from get_header means HTTP/0.9. In that case, skip
|
||||
* the get_http_code call; @h and @version have already been
|
||||
* initialized with the right values. */
|
||||
if (a == -2) a = 0;
|
||||
if ((a && get_http_code(rb, &h, &version))
|
||||
|| h == 101) {
|
||||
|
Loading…
Reference in New Issue
Block a user