commit c9e878d6a40f4b509bb8928e4736a63f8b7723a2 from: Omar Polo date: Mon Jun 26 10:17:43 2023 UTC use snprintf() instead of chain of strlcpy/cat commit - ed164e7221f75d3d7f48351e9427f2ce53ab284a commit + c9e878d6a40f4b509bb8928e4736a63f8b7723a2 blob - 09b26450753fa543bb800936d24f0430f8ff8055 blob + 0eebe46f41081f6afb9a60cea7a12493a1995e80 --- server.c +++ server.c @@ -907,13 +907,10 @@ open_dir(struct client *c) static void redirect_canonical_dir(struct client *c) { - size_t len; - - strlcpy(c->sbuf, "/", sizeof(c->sbuf)); - strlcat(c->sbuf, c->iri.path, sizeof(c->sbuf)); - len = strlcat(c->sbuf, "/", sizeof(c->sbuf)); + int r; - 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; }