Fix for issue #74 Someone forgot to subtract 1 from the lenght, resulting in a possible 1-byte buffer overflow.
@@ -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
@@ -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;