mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Replace va_list fmt() overload with vfmt()
Using an overload that takes a va_list argument potentially causes accidental misuse on platforms (e.g. 32-bit) where va_list is implemented as a type that may collide with commonly-used argument types. For example: char* c = copy_string("hi"); fmt("%s", (const char*)c); fmt("%s", c); The first fmt() call correctly goes through fmt(const char*, ...) first, but the second mistakenly goes through fmt(const char*, va_list) first because variadic function overloads have lower priority during overload resolution and va_list on a 32-bit system happens to be defined as a pointer type that can match with "char*" but not "const char*".
This commit is contained in:
parent
8e353aafe5
commit
8fed26824b
5 changed files with 11 additions and 5 deletions
|
@ -188,7 +188,7 @@ extern std::string strtolower(const std::string& s);
|
|||
extern const char* fmt_bytes(const char* data, int len);
|
||||
|
||||
// Note: returns a pointer into a shared buffer.
|
||||
extern const char* fmt(const char* format, va_list args);
|
||||
extern const char* vfmt(const char* format, va_list args);
|
||||
// Note: returns a pointer into a shared buffer.
|
||||
extern const char* fmt(const char* format, ...)
|
||||
__attribute__((format (printf, 1, 2)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue