diff options
| -rw-r--r-- | main.c | 50 |
1 files changed, 44 insertions, 6 deletions
@@ -147,9 +147,17 @@ static int login(const struct http_payload *const pl, int ret = -1; struct form *forms = NULL; const struct user_args *const ua = user; + const char *const data = pl->u.post.data; char *cookie = NULL; - if ((ret = form_alloc(pl->u.post.data, &forms))) + if (!data) + { + if ((ret = page_bad_request(r)) < 0) + fprintf(stderr, "%s: page_bad_requrest failed\n", __func__); + + goto end; + } + if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); @@ -381,6 +389,7 @@ static int check_search_input(const struct http_payload *const p, char **const dir, struct dynstr *const res) { int ret = auth_cookie(a, &p->cookie); + const char *const data = p->u.post.data; struct form *forms = NULL; if (ret < 0) @@ -393,7 +402,12 @@ static int check_search_input(const struct http_payload *const p, *f = page_forbidden; goto end; } - else if ((ret = form_alloc(p->u.post.data, &forms))) + else if (!data) + { + *f = page_bad_request; + goto end; + } + else if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); @@ -669,10 +683,16 @@ static int share(const struct http_payload *const p, struct form *forms = NULL; char *sympath = NULL; struct dynstr userpath; + const char *const data = p->u.post.data; dynstr_init(&userpath); - if ((ret = form_alloc(p->u.post.data, &forms))) + if (!data) + { + ret = page_bad_request(r); + goto end; + } + if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); @@ -1488,6 +1508,7 @@ static int createdir(const struct http_payload *const p, int ret = -1; const struct user_args *const ua = user; const struct auth *const a = ua->a; + const char *const data = p->u.post.data; struct dynstr d, userd; struct form *forms = NULL; char *encurl = NULL; @@ -1501,7 +1522,12 @@ static int createdir(const struct http_payload *const p, ret = page_forbidden(r); goto end; } - else if ((ret = form_alloc(p->u.post.data, &forms))) + else if (!data) + { + ret = page_bad_request(r); + goto end; + } + else if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); @@ -1681,6 +1707,7 @@ static int confirm_rm(const struct http_payload *const p, { int ret = -1; const struct user_args *const ua = user; + const char *const data = p->u.post.data; struct form *forms = NULL; const char **items = NULL; int (*f)(struct http_response *); @@ -1692,7 +1719,12 @@ static int confirm_rm(const struct http_payload *const p, ret = page_forbidden(r); goto end; } - else if ((ret = form_alloc(p->u.post.data, &forms))) + else if (!data) + { + ret = page_bad_request(r); + goto end; + } + else if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); @@ -1940,6 +1972,7 @@ static int rm(const struct http_payload *const p, struct form *forms = NULL; const struct http_cookie *const c = &p->cookie; const char *username = c->field, *adir; + const char *const data = p->u.post.data; struct dynstr d, userdir; dynstr_init(&d); @@ -1951,12 +1984,17 @@ static int rm(const struct http_payload *const p, ret = page_forbidden(r); goto end; } + else if (!data) + { + ret = page_bad_request(r); + goto end; + } else if (!(adir = auth_dir(a))) { fprintf(stderr, "%s: auth_dir failed\n", __func__); goto end; } - else if ((ret = form_alloc(p->u.post.data, &forms))) + else if ((ret = form_alloc(data, &forms))) { if (ret < 0) fprintf(stderr, "%s: get_forms failed\n", __func__); |
