From 041c190799fffc1c893093d3ce8e609b499f7b46 Mon Sep 17 00:00:00 2001 From: ck <84600276+critkitten@users.noreply.github.com> Date: Sun, 18 Jun 2023 17:46:23 +0200 Subject: [PATCH] =?UTF-8?q?fix=20warning:=20=E2=80=98strndup=E2=80=99=20sp?= =?UTF-8?q?ecified=20bound=204096=20exceeds=20source=20size=202=20[-Wstrin?= =?UTF-8?q?gop-overread]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘allocate_paths’, inlined from ‘xfer_options_parse_args’ at xfer-options.c:388:8: xfer-options.c:69:34: warning: ‘strndup’ specified bound 4096 exceeds source size 2 [-Wstringop-overread] 69 | xfer->paths[0] = strndup("-", PATH_MAX); | ^~~~~~~~~~~~~~~~~~~~~~ --- axfer/xfer-options.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/axfer/xfer-options.c b/axfer/xfer-options.c index 3740b16..bb26bbd 100644 --- a/axfer/xfer-options.c +++ b/axfer/xfer-options.c @@ -66,12 +66,12 @@ static int allocate_paths(struct xfer_context *xfer, char *const *paths, xfer->path_count = count; if (stdio) { - xfer->paths[0] = strndup("-", PATH_MAX); + xfer->paths[0] = strndup("-", strlen("-")); if (xfer->paths[0] == NULL) return -ENOMEM; } else { for (i = 0; i < count; ++i) { - xfer->paths[i] = strndup(paths[i], PATH_MAX); + xfer->paths[i] = strndup(paths[i], strlen(paths[i])); if (xfer->paths[i] == NULL) return -ENOMEM; }