From b8fc8b7f6207ea02c7ae2afb642e9cbef4426f8b Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 11 Mar 2025 09:30:46 +0100 Subject: [PATCH] bin: copy: fix segfault for one argument The code assumes both SRC and DST is passed, here we ensure this early. Prior to this patch: root@host:~$ copy foo Segmentation fault (core dumped) Signed-off-by: Richard Alpe --- src/bin/copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/copy.c b/src/bin/copy.c index 80235718..12e49e60 100644 --- a/src/bin/copy.c +++ b/src/bin/copy.c @@ -418,7 +418,7 @@ int main(int argc, char *argv[]) if (timeout < 0) timeout = 120; - if (optind >= argc) + if (argc - optind != 2) return usage(1); src = argv[optind++];