summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2025-02-11 15:38:21 +0000
committerGitHub <noreply@github.com>2025-02-11 15:38:21 +0000
commitb5bc748a38cf88e8fa52fb8f55bf8014a188a9b9 (patch)
treee1ec6f8c5b80fc3b6ba33fdf13eab8174893990a /src
parent6ab29905c094db8b961c64e1468a7ff274281352 (diff)
downloadipaddrcheck-b5bc748a38cf88e8fa52fb8f55bf8014a188a9b9.tar.gz
ipaddrcheck-b5bc748a38cf88e8fa52fb8f55bf8014a188a9b9.zip
T7156: suppress sprintf format warnings at the source level (#13)
rather than with CFLAGS, so that it applies only to locations where it was proven safe and is protected against CFLAGS overrides
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/ipaddrcheck_functions.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c43bae..6098ae5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-AM_CFLAGS = --pedantic -Wall -Werror -Wno-error=format-overflow= -std=c99 -O2
+AM_CFLAGS = --pedantic -Wall -Werror -std=c99 -O2
AM_LDFLAGS =
ipaddrcheck_SOURCES = ipaddrcheck.c ipaddrcheck_functions.c
diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c
index 034fd54..d486d07 100644
--- a/src/ipaddrcheck_functions.c
+++ b/src/ipaddrcheck_functions.c
@@ -578,10 +578,13 @@ int is_ipv4_range(char* range_str, int prefix_length, int verbose)
{
char left_pref_str[19];
- /* XXX: Prefix length size is checked elsewhere, so it can't be more than 2 characters (32)
+ /* XXX: Prefix length size is checked elsewhere with a regex, so it can't be more than 2 characters (32)
and overflow cannot occur.
*/
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wformat-overflow="
sprintf(left_pref_str, "%s/%u", left, prefix_length);
+ #pragma GCC diagnostic pop
CIDR* left_addr_with_pref = cidr_from_str(left_pref_str);
CIDR* left_net = cidr_addr_network(left_addr_with_pref);
if( cidr_contains(left_net, right_addr) == 0 )
@@ -679,10 +682,13 @@ int is_ipv6_range(char* range_str, int prefix_length, int verbose)
{
char left_pref_str[44];
- /* XXX: Prefix length size is checked elsewhere, so it can't be more than 3 characters (128)
+ /* XXX: Prefix length size is checked elsewhere with a regex, so it can't be more than 3 characters (128)
and overflow cannot occur.
*/
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wformat-overflow="
sprintf(left_pref_str, "%s/%u", left, prefix_length);
+ #pragma GCC diagnostic pop
CIDR* left_addr_with_pref = cidr_from_str(left_pref_str);
CIDR* left_net = cidr_addr_network(left_addr_with_pref);
if( cidr_contains(left_net, right_addr) == 0 )