diff options
author | Mukund Sivaraman <muks@banu.com> | 2008-07-14 17:13:06 +0530 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2008-07-14 17:13:06 +0530 |
commit | 7e5ac7c58a7a301d9c6d65bbc2c3632fc0fba5ed (patch) | |
tree | 91eb83170b3795cdec89750fb81cb46884ad0f8f /src | |
parent | 7bdd47d030d4cc27e319edf6030e161f25e1a299 (diff) | |
download | tinyproxy-7e5ac7c58a7a301d9c6d65bbc2c3632fc0fba5ed.tar.gz tinyproxy-7e5ac7c58a7a301d9c6d65bbc2c3632fc0fba5ed.zip |
Fix a regression where empty error variables caused strlen() to crash
This fixes a regression (bug #16) introduced in
95c1f39f6039dc82346f3e024e86a23b7103a0a6, where a NULL check was
removed. This caused NULL error variable values to be sent to
add_error_variable() in which strlen() segfaulted.
With this fix, custom stats pages should be displayed properly.
X-Banu-Bugzilla-Ids: 16
Diffstat (limited to 'src')
-rw-r--r-- | src/html-error.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/html-error.c b/src/html-error.c index c6b580e..1802cde 100644 --- a/src/html-error.c +++ b/src/html-error.c @@ -244,7 +244,9 @@ add_error_variable(struct conn_s *connptr, char *key, char *val) } #define ADD_VAR_RET(x, y) \ - do { \ + do { \ + if (y == NULL) \ + break; \ if (add_error_variable(connptr, x, y) < 0) \ return -1; \ } while (0) @@ -266,14 +268,20 @@ add_standard_vars(struct conn_s *connptr) ADD_VAR_RET("request", connptr->request_line); ADD_VAR_RET("clientip", connptr->client_ip_addr); ADD_VAR_RET("clienthost", connptr->client_string_addr); - ADD_VAR_RET("version", VERSION); - ADD_VAR_RET("package", PACKAGE); - ADD_VAR_RET("website", "http://tinyproxy.banu.com/"); + + /* The following value parts are all non-NULL and will + * trigger warnings in ADD_VAR_RET(), so we use + * add_error_variable() directly. + */ global_time = time(NULL); strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&global_time)); - ADD_VAR_RET("date", timebuf); + add_error_variable(connptr, "date", timebuf); + + add_error_variable(connptr, "website", "http://tinyproxy.banu.com/"); + add_error_variable(connptr, "version", VERSION); + add_error_variable(connptr, "package", PACKAGE); return (0); } |