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 --- ebtables-restore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 #include #include @@ -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]); -- 2.39.2