Просмотр исходного кода

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
Karl DeBisschop 23 лет назад
Родитель
Сommit
0505e9fb07
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      plugins/popen.c

+ 2 - 1
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;