From 0505e9fb07a5bd701efd3ce335a6dc8e13cbd6e1 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Mon, 7 Oct 2002 01:34:46 +0000 Subject: [PATCH] make sure we do not run past the end of an unterminated string git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@108 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/popen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/popen.c b/plugins/popen.c index cde3c76..d056904 100644 --- a/plugins/popen.c +++ b/plugins/popen.c @@ -302,8 +302,9 @@ char * rtrim (char *str, const char *tok) { int i = 0; + int j = sizeof (str); - while (str != NULL) { + while (str != NULL && i < j) { if (*(str + i) == *tok) { sprintf (str + i, "%s", "\0"); return str; -- 2.30.2