From 15375ba1e371f99c054b1c948546a5f180093604 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Mon, 17 Apr 2017 21:46:58 +0200 Subject: [PATCH] Guard a few more format strings with __attribute__((format)) This will cause compile-time error messages to be raised if someone passes incorrect parameters to these strings. --- src/Reporter.h | 6 +++--- src/input/Manager.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Reporter.h b/src/Reporter.h index 19cdbb7e82..85b9a483a2 100644 --- a/src/Reporter.h +++ b/src/Reporter.h @@ -66,11 +66,11 @@ public: // Report a runtime error in evaluating a Bro script expression. This // function will not return but raise an InterpreterException. - void ExprRuntimeError(const Expr* expr, const char* fmt, ...); + void ExprRuntimeError(const Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4))); // Report a runtime error in evaluating a Bro script expression. This // function will not return but raise an InterpreterException. - void RuntimeError(const Location* location, const char* fmt, ...); + void RuntimeError(const Location* location, const char* fmt, ...) __attribute__((format(printf, 3, 4))); // Report a traffic weirdness, i.e., an unexpected protocol situation // that may lead to incorrectly processing a connnection. @@ -123,7 +123,7 @@ public: private: void DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connection* conn, val_list* addl, bool location, bool time, - const char* postfix, const char* fmt, va_list ap); + const char* postfix, const char* fmt, va_list ap) __attribute__((format(printf, 10, 0))); // The order if addl, name needs to be like that since fmt_name can // contain format specifiers diff --git a/src/input/Manager.h b/src/input/Manager.h index e7a1ebe2d6..8296ce9f8b 100644 --- a/src/input/Manager.h +++ b/src/input/Manager.h @@ -240,7 +240,7 @@ private: enum class ErrorType { INFO, WARNING, ERROR }; void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) __attribute__((format(printf, 5, 6))); - void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap); + void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap) __attribute__((format(printf, 5, 0))); Stream* FindStream(const string &name); Stream* FindStream(ReaderFrontend* reader);