Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flawfinder: mark some ignores for CWE-134 in debug.h #447

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@
#define COLOR_END "\e[0m"
#endif

/* Many of these debug printf include a Flawfinder: ignore, this is because,
* according to https://cwe.mitre.org/data/definitions/134.html which describes
* functions that accepts a format string as an argument, but the format
* string originates from an external source. All the IIO_DEBUG, IIO_INFO,
* IIO_WARNING, and IIO_ERRRO functions are called internally from the
* library, have fixed format strings and can not be modified externally.
*/
#if (LOG_LEVEL >= Debug_L)
# ifdef COLOR_DEBUG
# define IIO_DEBUG(str, ...) \
fprintf(stdout, COLOR_DEBUG "DEBUG: " str COLOR_END, ##__VA_ARGS__)
fprintf(stdout, COLOR_DEBUG "DEBUG: " str COLOR_END, ##__VA_ARGS__) /* Flawfinder: ignore */
# else
# define IIO_DEBUG(...) \
fprintf(stdout, "DEBUG: " __VA_ARGS__)
fprintf(stdout, "DEBUG: " __VA_ARGS__) /* Flawfinder: ignore */
# endif
#else
#define IIO_DEBUG(...) do { } while (0)
Expand All @@ -60,10 +67,10 @@
#if (LOG_LEVEL >= Info_L)
# ifdef COLOR_INFO
# define IIO_INFO(str, ...) \
fprintf(stdout, COLOR_INFO str COLOR_END, ##__VA_ARGS__)
fprintf(stdout, COLOR_INFO str COLOR_END, ##__VA_ARGS__) /* Flawfinder: ignore */
# else
# define IIO_INFO(...) \
fprintf(stdout, __VA_ARGS__)
fprintf(stdout, __VA_ARGS__) /* Flawfinder: ignore */
# endif
#else
#define IIO_INFO(...) do { } while (0)
Expand All @@ -72,10 +79,10 @@
#if (LOG_LEVEL >= Warning_L)
# ifdef COLOR_WARNING
# define IIO_WARNING(str, ...) \
fprintf(stderr, COLOR_WARNING "WARNING: " str COLOR_END, ##__VA_ARGS__)
fprintf(stderr, COLOR_WARNING "WARNING: " str COLOR_END, ##__VA_ARGS__) /* Flawfinder: ignore */
# else
# define IIO_WARNING(...) \
fprintf(stderr, "WARNING: " __VA_ARGS__)
fprintf(stderr, "WARNING: " __VA_ARGS__) /* Flawfinder: ignore */
# endif
#else
#define IIO_WARNING(...) do { } while (0)
Expand All @@ -84,10 +91,10 @@
#if (LOG_LEVEL >= Error_L)
# ifdef COLOR_ERROR
# define IIO_ERROR(str, ...) \
fprintf(stderr, COLOR_ERROR "ERROR: " str COLOR_END, ##__VA_ARGS__)
fprintf(stderr, COLOR_ERROR "ERROR: " str COLOR_END, ##__VA_ARGS__) /* Flawfinder: ignore */
# else
# define IIO_ERROR(...) \
fprintf(stderr, "ERROR: " __VA_ARGS__)
fprintf(stderr, "ERROR: " __VA_ARGS__) /* Flawfinder: ignore */
# endif
#else
#define IIO_ERROR(...) do { } while (0)
Expand Down