From d03fe10be86b14b1e440d9cf5dcd2012db1e9e83 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 21 Jun 2024 14:09:41 +0200 Subject: [PATCH] Protect printf-like calls against format errors --- src/common.c | 6 +++--- src/emu/chan.c | 2 +- src/emu/track.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common.c b/src/common.c index 44221c7..d27a55c 100644 --- a/src/common.c +++ b/src/common.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: MIT */ #include "common.h" @@ -56,7 +56,7 @@ vaerr(const char *prefix, const char *func, const char *errstr, va_list ap) } } -void +void __attribute__((format(printf, 3, 4))) verr(const char *prefix, const char *func, const char *errstr, ...) { va_list ap; @@ -65,7 +65,7 @@ verr(const char *prefix, const char *func, const char *errstr, ...) va_end(ap); } -void +void __attribute__((format(printf, 3, 4))) vdie(const char *prefix, const char *func, const char *errstr, ...) { va_list ap; diff --git a/src/emu/chan.c b/src/emu/chan.c index 4832bef..c9de48a 100644 --- a/src/emu/chan.c +++ b/src/emu/chan.c @@ -7,7 +7,7 @@ #include #include "common.h" -void +void __attribute__((format(printf, 3, 4))) chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) { memset(chan, 0, sizeof(struct chan)); diff --git a/src/emu/track.c b/src/emu/track.c index f7d313c..0516be2 100644 --- a/src/emu/track.c +++ b/src/emu/track.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "track.h" @@ -17,7 +17,7 @@ static const char **track_suffix[TRACK_TYPE_MAX] = { [TRACK_TYPE_TH] = th_suffix, }; -int +int __attribute__((format(printf, 5, 6))) track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...) { va_list ap;