diff options
author | Omar Polo <op@omarpolo.com> | 2023-06-26 10:17:43 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-06-26 10:17:43 +0000 |
commit | c9e878d6a40f4b509bb8928e4736a63f8b7723a2 (patch) | |
tree | 6561c410a52151ceca9ed0a5f8a86128bb0a2b10 /server.c | |
parent | ed164e7221f75d3d7f48351e9427f2ce53ab284a (diff) |
use snprintf() instead of chain of strlcpy/cat
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -907,13 +907,10 @@ open_dir(struct client *c) static void redirect_canonical_dir(struct client *c) { - size_t len; + int r; - strlcpy(c->sbuf, "/", sizeof(c->sbuf)); - strlcat(c->sbuf, c->iri.path, sizeof(c->sbuf)); - len = strlcat(c->sbuf, "/", sizeof(c->sbuf)); - - if (len >= sizeof(c->sbuf)) { + r = snprintf(c->sbuf, sizeof(c->sbuf), "/%s/", c->iri.path); + if (r < 0 || (size_t)r >= sizeof(c->sbuf)) { start_reply(c, TEMP_FAILURE, "internal server error"); return; } |