1From 6745b6362681f57823a57575a7949bd510767ac4 Mon Sep 17 00:00:00 2001
2From: Mikael Voss <mvs@nyantec.com>
3Date: Wed, 23 Jul 2025 18:37:10 +0200
4Subject: [PATCH 1/2] Replace unsound use of EOF
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9While getopt_long returns -1 on error, EOF is an implementation‐defined
10negative integer constant that just happens to be defined as -1 by most
11C standard libraries.
12---
13 prctl.c | 4 ++--
14 1 file changed, 2 insertions(+), 2 deletions(-)
15
16diff --git a/prctl.c b/prctl.c
17index 38cbcd1..527584c 100644
18--- a/prctl.c
19+++ b/prctl.c
20@@ -299,8 +299,8 @@ main(int argc, char **argv)
21 exit(1);
22 }
23 opterr = 0;
24- while ((opt = getopt_long(argc, argv, "+qhv", longopts,
25- (int *) NULL)) != EOF) {
26+ while ((opt = getopt_long(argc, argv, "+qhv", longopts,
27+ (int *) NULL)) != -1) {
28 switch (opt) {
29 case 'u':
30 if (strcmp(optarg, "silent") == 0) {
31
32From 0c11b937c30e41e97c3fa852f6d65cd595bc193f Mon Sep 17 00:00:00 2001
33From: Mikael Voss <mvs@nyantec.com>
34Date: Wed, 23 Jul 2025 18:54:39 +0200
35Subject: [PATCH 2/2] Properly display invalid long options
36
37---
38 prctl.c | 4 ++--
39 1 file changed, 2 insertions(+), 2 deletions(-)
40
41diff --git a/prctl.c b/prctl.c
42index 527584c..4c1d632 100644
43--- a/prctl.c
44+++ b/prctl.c
45@@ -375,8 +375,8 @@ main(int argc, char **argv)
46 break;
47
48 case '?':
49- fprintf(stderr, "%s: invalid option - %c\n",
50- progname, optopt);
51+ fprintf(stderr, "%s: invalid option: %s\n",
52+ progname, argv[optind - 1]);
53 exit(1);
54 break;
55 }