Skip to contentSkip to conversation

ebtables: fix null dereference in ebtables-restore

PATCH New Ilia Kashintsev 1 participant 1 message Dec 25, 2025 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ebtables: fix null dereference in ebtables-restore

Use strchrnul() instead of strchr() when trimming the trailing newline. This avoids NULL pointer dereference when newline is not present in the input.

---
 ebtables-restore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ebtables-restore.c +2 -1
index bb4d0cf..d7df38c 100644
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -76,7 +77,7 @@ int main(int argc_, char *argv_[])
 		line++;
 		if (*cmdline == '#' || *cmdline == '\n')
 			continue;
-		*strchr(cmdline, '\n') = '\0';
+		*strchrnul(cmdline, '\n') = '\0';
 		if (*cmdline == '*') {
 			if (table_nr != -1) {
 				ebt_deliver_table(&replace[table_nr]);
Signature · 1 line
2.39.2