Browse Source

Off-by-one BO in my_system()

Fix for issue #74

Someone forgot to subtract 1 from the lenght, resulting in a
possible 1-byte buffer overflow.
John C. Frickson 9 years ago
parent
commit
aed42f9401
2 changed files with 2 additions and 1 deletions
  1. 1 0
      Changelog
  2. 1 1
      src/nrpe.c

+ 1 - 0
Changelog

@@ -15,6 +15,7 @@ FIXES
 - Removed function `b64_decode` which wasn't being used (John Frickson)
 - check_nrpe ignores -a option when -f option is specified (John Frickson)
 - Added missing LICENSE file (John Frickson)
+- Off-by-one BO in my_system() (John Frickson)
 
 
 3.0.1 - 2016-09-08

+ 1 - 1
src/nrpe.c

@@ -2125,7 +2125,7 @@ int my_system(char *command, int timeout, int *early_timeout, char **output)
 					break;
 			}
 			if (tot_bytes < output_size)	/* If buffer is full, discard the rest */
-				strncat(*output, buffer, output_size - tot_bytes);
+				strncat(*output, buffer, output_size - tot_bytes - 1);
 			tot_bytes += bytes_read;
 		}