From 9abbe8cc136e7fbc69004df3f1de9d54c40d969d Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Fri, 17 Jun 2011 10:31:11 +0300 Subject: Use av_printf_format to check the usage of printf style functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps catching cases where the format string doesn't match what is passed in, or injection bugs where user data is passed in as format string. Signed-off-by: Martin Storsjö --- libavutil/avstring.h | 3 ++- libavutil/log.h | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'libavutil') diff --git a/libavutil/avstring.h b/libavutil/avstring.h index b40acf6ebb..44ed89d654 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -22,6 +22,7 @@ #define AVUTIL_AVSTRING_H #include +#include "attributes.h" /** * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to @@ -107,7 +108,7 @@ size_t av_strlcat(char *dst, const char *src, size_t size); * @return the length of the string that would have been generated * if enough space had been available */ -size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...); +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); /** * Convert a number to a av_malloced string. diff --git a/libavutil/log.h b/libavutil/log.h index c823a763ee..c1d9a6c393 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -23,6 +23,7 @@ #include #include "avutil.h" +#include "attributes.h" /** * Describe the class of an AVClass context structure. That is an @@ -129,11 +130,7 @@ typedef struct { * subsequent arguments are converted to output. * @see av_vlog */ -#ifdef __GNUC__ -void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -#else -void av_log(void *avcl, int level, const char *fmt, ...); -#endif +void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); void av_vlog(void *avcl, int level, const char *fmt, va_list); int av_log_get_level(void); -- cgit v1.2.3