[master] 2f0e4b128 vtim: Harden VTIM_format() prototype
Nils Goroll
nils.goroll at uplex.de
Wed May 28 15:16:05 UTC 2025
commit 2f0e4b1283fb3c8edb0c187cba10310424f3b6b1
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed May 21 16:23:00 2025 +0200
vtim: Harden VTIM_format() prototype
This should allow compilers and static analyzers to complain about
buffers too small, and this emphasizes the difference between the
format and parse operations and how they treat their respective
string arguments.
diff --git a/include/vtim.h b/include/vtim.h
index 9652238c0..75f7a9cbe 100644
--- a/include/vtim.h
+++ b/include/vtim.h
@@ -33,7 +33,7 @@
/* from libvarnish/vtim.c */
extern unsigned VTIM_postel;
#define VTIM_FORMAT_SIZE 30
-void VTIM_format(vtim_real t, char *p);
+void VTIM_format(vtim_real t, char p[VTIM_FORMAT_SIZE]);
vtim_real VTIM_parse(const char *p);
vtim_mono VTIM_mono(void);
vtim_real VTIM_real(void);
diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index af46aa665..e023569e7 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -157,7 +157,7 @@ VTIM_real(void)
}
void
-VTIM_format(vtim_real t, char *p)
+VTIM_format(vtim_real t, char p[VTIM_FORMAT_SIZE])
{
struct tm tm;
time_t tt;
More information about the varnish-commit
mailing list