aboutsummaryrefslogtreecommitdiff
path: root/ge.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-06-06 08:22:18 +0000
committerOmar Polo <op@omarpolo.com>2023-06-06 08:22:18 +0000
commit4267093e37fd7cded943399af8afe3ba825a1e68 (patch)
treea045727475f33bd1624947d6443a0ade29ab4056 /ge.c
parentf057c9262272dcbb93085cde46019e1f62bc541a (diff)
nitpick: fix snprintf check
Diffstat (limited to 'ge.c')
-rw-r--r--ge.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ge.c b/ge.c
index 6afe035..af85343 100644
--- a/ge.c
+++ b/ge.c
@@ -139,11 +139,12 @@ static int
serve(const char *host, int port, const char *dir)
{
struct addrinfo hints, *res, *res0;
- int error, saved_errno, sock = -1;
+ int r, error, saved_errno, sock = -1;
const char *cause = NULL;
char service[32];
- if (snprintf(service, sizeof(service), "%d", port) < 0)
+ r = snprintf(service, sizeof(service), "%d", port);
+ if (r < 0 || (size_t)r >= sizeof(service))
fatal("snprintf");
memset(&hints, 0, sizeof(hints));