aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2024-06-10 08:20:35 +0000
committerOmar Polo <op@omarpolo.com>2024-06-10 08:20:35 +0000
commitcf6269349513c87a6660d9e5bb8c2d20e628d195 (patch)
tree16a2067d1fb398628f691abc5ce5f73b4dcc527d
parent62aa1935cc563f864635bb9ee0b1204752168fe6 (diff)
gg: use snprintf
-rw-r--r--gg.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gg.c b/gg.c
index 21bbe36..5ca3fc7 100644
--- a/gg.c
+++ b/gg.c
@@ -213,14 +213,13 @@ get(const char *r)
char req[GEMINI_URL_LEN];
uint8_t buf[2048];
const char *parse_err, *host, *port;
+ int ret;
if (strlcpy(iribuf, r, sizeof(iribuf)) >= sizeof(iribuf))
errx(1, "iri too long: %s", r);
- if (strlcpy(req, r, sizeof(req)) >= sizeof(req))
- errx(1, "iri too long: %s", r);
-
- if (strlcat(req, "\r\n", sizeof(req)) >= sizeof(req))
+ ret = snprintf(req, sizeof(req), "%s\r\n", r);
+ if (ret < 0 || (size_t)ret >= sizeof(req))
errx(1, "iri too long: %s", r);
if (!parse_iri(iribuf, &iri, &parse_err))