Skip to content

Commit

Permalink
Fix bad buffer length in {http,supemb}_is_valid_uri() (reported by Se…
Browse files Browse the repository at this point in the history
…nén de Diego)
  • Loading branch information
stewy committed Dec 28, 2011
1 parent fc5f108 commit ec3da81
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ KLone 3.0.0:
values (reported and fixed by Davide Berra)
- Fix SSL compilation flags missing during cross-compilation
- Fix partially uploaded files not cleaned up
- Fix bad buffer length in {http,supemb}_is_valid_uri() (reported by
Senén de Diego)

KLone 2.4.0:
- max size estimate of encrypted sessions fixed (session_prv_calc_maxsize)
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Christian Kelinski kelinski at gmail.com
Kari Pahula kaol at iki.fi
Mark Richards mark.richards at massmicro.com
Steven Van Ingelgem steven at vaningelgem.be
Senén de Diego atinar1@hotmail.com
5 changes: 4 additions & 1 deletion src/libhttp/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,12 @@ static int http_is_valid_uri(request_t *rq, const char *buf, size_t len)

dbg_err_if (rq == NULL);
dbg_err_if (buf == NULL);
dbg_err_if (len + 1 > URI_MAX);

dbg_err_if ((h = request_get_http(rq)) == NULL);
dbg_err_if (u_strlcpy(uri, buf, sizeof uri));

memcpy(uri, buf, len);
uri[len] = '\0';

/* try the url itself */
if(broker_is_valid_uri(h->broker, h, rq, uri, strlen(uri)))
Expand Down
4 changes: 3 additions & 1 deletion src/libhttp/sup_emb.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ static int supemb_is_valid_uri(http_t *h, request_t *rq, const char *uri,

dbg_err_if (uri == NULL);
dbg_err_if (mtime == NULL);
dbg_err_if (len + 1 > U_FILENAME_MAX);

u_unused_args(h, rq);

dbg_err_if (u_strlcpy(filename, uri, sizeof filename));
memcpy(filename, uri, len);
filename[len] = '\0';

if(emb_lookup(filename, &e) == 0)
{ /* resource found */
Expand Down

0 comments on commit ec3da81

Please sign in to comment.