aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-06-26 10:17:43 +0000
committerOmar Polo <op@omarpolo.com>2023-06-26 10:17:43 +0000
commitc9e878d6a40f4b509bb8928e4736a63f8b7723a2 (patch)
tree6561c410a52151ceca9ed0a5f8a86128bb0a2b10 /server.c
parented164e7221f75d3d7f48351e9427f2ce53ab284a (diff)
use snprintf() instead of chain of strlcpy/cat
Diffstat (limited to 'server.c')
-rw-r--r--server.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/server.c b/server.c
index 09b2645..0eebe46 100644
--- a/server.c
+++ b/server.c
@@ -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;
}