|
|
4a3166 |
From 6dda36aceaedf88b33e5a2cf216bbd3b047611a6 Mon Sep 17 00:00:00 2001
|
|
|
4a3166 |
From: Florian Westphal <fw@strlen.de>
|
|
|
4a3166 |
Date: Mon, 17 Jan 2022 16:42:52 +0100
|
|
|
4a3166 |
Subject: [PATCH] conntrack: fix compiler warnings
|
|
|
4a3166 |
|
|
|
4a3166 |
.... those do not indicate bugs, but they are distracting.
|
|
|
4a3166 |
|
|
|
4a3166 |
'exp_filter_add' at filter.c:513:2:
|
|
|
4a3166 |
__builtin_strncpy specified bound 16 equals destination size [-Wstringop-truncation]
|
|
|
4a3166 |
|
|
|
4a3166 |
This warning is because the size argument passed to strncpy() is
|
|
|
4a3166 |
identical to buffer size, i.e. if hit the resulting string is not
|
|
|
4a3166 |
0-terminated.
|
|
|
4a3166 |
|
|
|
4a3166 |
read_config_yy.y:1625: warning: '__builtin_snprintf' output may be truncated before the last format character [-Wformat-truncation=]
|
|
|
4a3166 |
1625 | snprintf(policy->name, CTD_HELPER_NAME_LEN, "%s", $2);
|
|
|
4a3166 |
read_config_yy.y:1399: warning: '__builtin_snprintf' output may be ...
|
|
|
4a3166 |
1399 | snprintf(conf.stats.logfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
read_config_yy.y:707: warning: '__builtin_snprintf' output may be ...
|
|
|
4a3166 |
707 | snprintf(conf.local.path, UNIX_PATH_MAX, "%s", $2);
|
|
|
4a3166 |
read_config_yy.y:179: warning: '__builtin_snprintf' output may be ...
|
|
|
4a3166 |
179 | snprintf(conf.lockfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
read_config_yy.y:124: warning: '__builtin_snprintf' output may be ...
|
|
|
4a3166 |
124 | snprintf(conf.logfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
|
|
|
4a3166 |
... its because the _MAXLEN constants are one less than the output
|
|
|
4a3166 |
buffer size, i.e. could use either .._MAXLEN + 1 or sizeof, this uses
|
|
|
4a3166 |
sizeof().
|
|
|
4a3166 |
|
|
|
4a3166 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
4a3166 |
(cherry picked from commit 5f15bb47bbcdb7581c80c5e488cd109450494ec2)
|
|
|
4a3166 |
---
|
|
|
4a3166 |
src/filter.c | 2 +-
|
|
|
4a3166 |
src/read_config_yy.y | 10 +++++-----
|
|
|
4a3166 |
2 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
4a3166 |
|
|
|
4a3166 |
diff --git a/src/filter.c b/src/filter.c
|
|
|
4a3166 |
index 00a5e96ecc248..9f961b1fe5b1b 100644
|
|
|
4a3166 |
--- a/src/filter.c
|
|
|
4a3166 |
+++ b/src/filter.c
|
|
|
4a3166 |
@@ -470,7 +470,7 @@ struct exp_filter *exp_filter_create(void)
|
|
|
4a3166 |
|
|
|
4a3166 |
struct exp_filter_item {
|
|
|
4a3166 |
struct list_head head;
|
|
|
4a3166 |
- char helper_name[NFCT_HELPER_NAME_MAX];
|
|
|
4a3166 |
+ char helper_name[NFCT_HELPER_NAME_MAX + 1];
|
|
|
4a3166 |
};
|
|
|
4a3166 |
|
|
|
4a3166 |
/* this is ugly, but it simplifies read_config_yy.y */
|
|
|
4a3166 |
diff --git a/src/read_config_yy.y b/src/read_config_yy.y
|
|
|
4a3166 |
index d963c494be1fc..401a1575014d0 100644
|
|
|
4a3166 |
--- a/src/read_config_yy.y
|
|
|
4a3166 |
+++ b/src/read_config_yy.y
|
|
|
4a3166 |
@@ -121,7 +121,7 @@ logfile_path : T_LOG T_PATH_VAL
|
|
|
4a3166 |
FILENAME_MAXLEN);
|
|
|
4a3166 |
exit(EXIT_FAILURE);
|
|
|
4a3166 |
}
|
|
|
4a3166 |
- snprintf(conf.logfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
+ snprintf(conf.logfile, sizeof(conf.logfile), "%s", $2);
|
|
|
4a3166 |
free($2);
|
|
|
4a3166 |
};
|
|
|
4a3166 |
|
|
|
4a3166 |
@@ -176,7 +176,7 @@ lock : T_LOCK T_PATH_VAL
|
|
|
4a3166 |
FILENAME_MAXLEN);
|
|
|
4a3166 |
exit(EXIT_FAILURE);
|
|
|
4a3166 |
}
|
|
|
4a3166 |
- snprintf(conf.lockfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
+ snprintf(conf.lockfile, sizeof(conf.lockfile), "%s", $2);
|
|
|
4a3166 |
free($2);
|
|
|
4a3166 |
};
|
|
|
4a3166 |
|
|
|
4a3166 |
@@ -704,7 +704,7 @@ unix_option : T_PATH T_PATH_VAL
|
|
|
4a3166 |
UNIX_PATH_MAX);
|
|
|
4a3166 |
exit(EXIT_FAILURE);
|
|
|
4a3166 |
}
|
|
|
4a3166 |
- snprintf(conf.local.path, UNIX_PATH_MAX, "%s", $2);
|
|
|
4a3166 |
+ snprintf(conf.local.path, sizeof(conf.local.path), "%s", $2);
|
|
|
4a3166 |
free($2);
|
|
|
4a3166 |
};
|
|
|
4a3166 |
|
|
|
4a3166 |
@@ -1396,7 +1396,7 @@ stat_logfile_path : T_LOG T_PATH_VAL
|
|
|
4a3166 |
FILENAME_MAXLEN);
|
|
|
4a3166 |
exit(EXIT_FAILURE);
|
|
|
4a3166 |
}
|
|
|
4a3166 |
- snprintf(conf.stats.logfile, FILENAME_MAXLEN, "%s", $2);
|
|
|
4a3166 |
+ snprintf(conf.stats.logfile, sizeof(conf.stats.logfile), "%s", $2);
|
|
|
4a3166 |
free($2);
|
|
|
4a3166 |
};
|
|
|
4a3166 |
|
|
|
4a3166 |
@@ -1611,7 +1611,7 @@ helper_type: T_HELPER_POLICY T_STRING '{' helper_policy_list '}'
|
|
|
4a3166 |
}
|
|
|
4a3166 |
|
|
|
4a3166 |
policy = (struct ctd_helper_policy *) &e->data;
|
|
|
4a3166 |
- snprintf(policy->name, CTD_HELPER_NAME_LEN, "%s", $2);
|
|
|
4a3166 |
+ snprintf(policy->name, sizeof(policy->name), "%s", $2);
|
|
|
4a3166 |
free($2);
|
|
|
4a3166 |
/* Now object is complete. */
|
|
|
4a3166 |
e->type = SYMBOL_HELPER_POLICY_EXPECT_ROOT;
|
|
|
4a3166 |
--
|
|
|
4a3166 |
2.34.1
|
|
|
4a3166 |
|