Thread (6 messages) 6 messages, 2 authors, 2025-08-20

[PATCH v2] man/man3/strftime.3: Check parameter

From: <hidden>
Date: 2025-08-18 17:45:55
Subsystem: the rest · Maintainer: Linus Torvalds

From: "Dr. David Alan Gilbert" <redacted>

The strftime example requires a format paramter.  If you don't
pass one it crashes.
Check for the parameter.

Signed-off-by: Dr. David Alan Gilbert <redacted>
---
 v2
    Use a more standard Usage: format.

 man/man3/strftime.3 | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/man/man3/strftime.3 b/man/man3/strftime.3
index 4a3f805bb..a27dfd01b 100644
--- a/man/man3/strftime.3
+++ b/man/man3/strftime.3
@@ -739,6 +739,11 @@ .SS Program source
     char outstr[200];
     time_t t;
     struct tm *tmp;
+\&
+    if (argc != 2) {
+        fprintf(stderr,"Usage: %s: <format\-string>\[rs]n", argv[0]);
+        exit(EXIT_FAILURE);
+    }
 \&
     t = time(NULL);
     tmp = localtime(&t);
-- 
2.50.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help