diff options
| author | Ilia Kashintsev <ilia.kashintsev@gmail.com> | 2025-12-25 15:32:34 +0300 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2026-01-01 11:33:53 +0100 |
| commit | a6f972845fcf3ef13a3481af1a8f5ca15ae96cfc (patch) | |
| tree | af2ab1605768142907877c55016340017b036ab7 | |
| parent | a7202b6caf9e96755152699c134b1a0ccc37c187 (diff) | |
Use strchrnul() instead of strchr() when trimming the trailing newline.
This avoids NULL pointer dereference when newline is not present in the
input.
Signed-off-by: Ilia Kashintsev <ilia.kashintsev@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
| -rw-r--r-- | ebtables-restore.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ebtables-restore.c b/ebtables-restore.c index bb4d0cf..d7df38c 100644 --- a/ebtables-restore.c +++ b/ebtables-restore.c @@ -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]); |
