Compare commits

...
7 Commits
Author SHA1 Message Date
Sergey Lyubka c41a22195c Merge pull request #1020 from nliviu/patch-2
Fix ASAN build for examples/cookie_auth
2019-09-30 07:46:39 +01:00
Sergey Lyubka 900c05213b 6.15 -> 6.16 2019-09-30 07:44:10 +01:00
Sergey c5850e4b05 Merge branch 'dev' 2019-09-30 07:41:04 +01:00
Sergey Lyubka ff4649fe42 Better UI
PUBLISHED_FROM=50f0cafa84cd06428f0da376d85766dcf62af9da
2019-07-12 12:33:28 +00:00
Sergey Lyubka 1a38e91042 Next
PUBLISHED_FROM=6fa0be81ce429b8db9e3ed572cb4a876b6fb2693
2019-07-12 09:33:26 +00:00
Sergey Lyubka b6196371bb Lsm
PUBLISHED_FROM=18d9d1e6411db84788c527d1c34ad2adc846df00
2019-06-26 10:33:24 +00:00
Liviu 12339bbf4c Fix ASAN build
The ASAN build fails with
```
cookie_auth.c:62:7: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
  if (cookie_header == NULL) goto clean;
      ^~~~~~~~~~~~~~~~~~~~~
cookie_auth.c:84:10: note: uninitialized use occurs here
  return ret;
         ^~~
cookie_auth.c:62:3: note: remove the 'if' if its condition is always false
  if (cookie_header == NULL) goto clean;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cookie_auth.c:65:3: note: variable 'ret' is declared here
  struct session *ret = NULL;
  ^
cookie_auth.c:62:7: error: variable 'ssid' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
  if (cookie_header == NULL) goto clean;
      ^~~~~~~~~~~~~~~~~~~~~
cookie_auth.c:81:7: note: uninitialized use occurs here
  if (ssid != ssid_buf) {
      ^~~~
cookie_auth.c:62:3: note: remove the 'if' if its condition is always false
  if (cookie_header == NULL) goto clean;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cookie_auth.c:64:3: note: variable 'ssid' is declared here
  char *ssid = ssid_buf;
  ^
2 errors generated.
```
2019-05-08 14:54:31 +03:00
6 changed files with 20 additions and 6 deletions

No files matched your search

+2 -2
View File
@@ -58,11 +58,11 @@ static int check_pass(const char *user, const char *pass) {
* or NULL if not found. * or NULL if not found.
*/ */
static struct session *get_session(struct http_message *hm) { static struct session *get_session(struct http_message *hm) {
struct mg_str *cookie_header = mg_get_http_header(hm, "cookie");
if (cookie_header == NULL) goto clean;
char ssid_buf[21]; char ssid_buf[21];
char *ssid = ssid_buf; char *ssid = ssid_buf;
struct session *ret = NULL; struct session *ret = NULL;
struct mg_str *cookie_header = mg_get_http_header(hm, "cookie");
if (cookie_header == NULL) goto clean;
if (!mg_http_parse_header2(cookie_header, SESSION_COOKIE_NAME, &ssid, if (!mg_http_parse_header2(cookie_header, SESSION_COOKIE_NAME, &ssid,
sizeof(ssid_buf))) { sizeof(ssid_buf))) {
goto clean; goto clean;
+2 -1
View File
@@ -6289,7 +6289,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
} }
} else { } else {
s = mg_skip(s, end, " ", &hm->proto); s = mg_skip(s, end, " ", &hm->proto);
if (end - s < 4 || s[3] != ' ') return -1; if (end - s < 4 || s[0] < '0' || s[0] > '9' || s[3] != ' ') return -1;
hm->resp_code = atoi(s); hm->resp_code = atoi(s);
if (hm->resp_code < 100 || hm->resp_code >= 600) return -1; if (hm->resp_code < 100 || hm->resp_code >= 600) return -1;
s += 4; s += 4;
@@ -6590,6 +6590,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
struct mg_http_multipart_part mp; struct mg_http_multipart_part mp;
memset(&mp, 0, sizeof(mp)); memset(&mp, 0, sizeof(mp));
mp.status = -1; mp.status = -1;
mp.user_data = pd->mp_stream.user_data;
mp.var_name = pd->mp_stream.var_name; mp.var_name = pd->mp_stream.var_name;
mp.file_name = pd->mp_stream.file_name; mp.file_name = pd->mp_stream.file_name;
mg_call(nc, (pd->endpoint_handler ? pd->endpoint_handler : nc->handler), mg_call(nc, (pd->endpoint_handler ? pd->endpoint_handler : nc->handler),
+1 -1
View File
@@ -23,7 +23,7 @@
#ifndef CS_MONGOOSE_SRC_COMMON_H_ #ifndef CS_MONGOOSE_SRC_COMMON_H_
#define CS_MONGOOSE_SRC_COMMON_H_ #define CS_MONGOOSE_SRC_COMMON_H_
#define MG_VERSION "6.15" #define MG_VERSION "6.16"
/* Local tweaks, applied before any of Mongoose's own headers. */ /* Local tweaks, applied before any of Mongoose's own headers. */
#ifdef MG_LOCALS #ifdef MG_LOCALS
+2 -1
View File
@@ -455,7 +455,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
} }
} else { } else {
s = mg_skip(s, end, " ", &hm->proto); s = mg_skip(s, end, " ", &hm->proto);
if (end - s < 4 || s[3] != ' ') return -1; if (end - s < 4 || s[0] < '0' || s[0] > '9' || s[3] != ' ') return -1;
hm->resp_code = atoi(s); hm->resp_code = atoi(s);
if (hm->resp_code < 100 || hm->resp_code >= 600) return -1; if (hm->resp_code < 100 || hm->resp_code >= 600) return -1;
s += 4; s += 4;
@@ -756,6 +756,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
struct mg_http_multipart_part mp; struct mg_http_multipart_part mp;
memset(&mp, 0, sizeof(mp)); memset(&mp, 0, sizeof(mp));
mp.status = -1; mp.status = -1;
mp.user_data = pd->mp_stream.user_data;
mp.var_name = pd->mp_stream.var_name; mp.var_name = pd->mp_stream.var_name;
mp.file_name = pd->mp_stream.file_name; mp.file_name = pd->mp_stream.file_name;
mg_call(nc, (pd->endpoint_handler ? pd->endpoint_handler : nc->handler), mg_call(nc, (pd->endpoint_handler ? pd->endpoint_handler : nc->handler),
+5 -1
View File
@@ -17,7 +17,7 @@ else
COMMON_PARENT = $(SRC_DIR) COMMON_PARENT = $(SRC_DIR)
endif endif
TEST_SOURCES = unit_test.c test_util.c test_main.c TEST_SOURCES = unit_test.c test_util.c test_main.c fuzz.c
AMALGAMATED_SOURCES = ../mongoose.c AMALGAMATED_SOURCES = ../mongoose.c
KRYPTON_PATH = $(REPO_ROOT)/krypton KRYPTON_PATH = $(REPO_ROOT)/krypton
@@ -118,6 +118,10 @@ clean_index_cgi:
@echo -e "CLEAN\tindex.cgi" @echo -e "CLEAN\tindex.cgi"
@rm -f data/cgi/index.cgi* @rm -f data/cgi/index.cgi*
fuzz:
$(CC) fuzz.c ../mongoose.c -o /tmp/$@ -fsanitize=fuzzer,address -g -I..
/tmp/$@
# Interactive: # Interactive:
# docker run -v $(CURDIR)/../..:/cesanta -t -i --entrypoint=/bin/bash cesanta/mongoose_test # docker run -v $(CURDIR)/../..:/cesanta -t -i --entrypoint=/bin/bash cesanta/mongoose_test
docker: docker:
+8
View File
@@ -0,0 +1,8 @@
#include "mongoose.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct http_message req;
mg_parse_http((const char *) data, size, &req, 0);
mg_parse_http((const char *) data, size, &req, 1);
return 0;
}