nmeter: fix read past the end if a buffer. Closes 4594

This commit is contained in:
Denis Vlasenko 2008-08-14 21:57:43 +00:00
parent ee777c4e5f
commit cd785fb716

View File

@ -786,8 +786,10 @@ int nmeter_main(int argc, char **argv)
if (argc != 2) if (argc != 2)
bb_show_usage(); bb_show_usage();
if (open_read_close("version", buf, sizeof(buf)) > 0) if (open_read_close("version", buf, sizeof(buf)-1) > 0) {
is26 = (strstr(buf, " 2.4.")==NULL); buf[sizeof(buf)-1] = '\0';
is26 = (strstr(buf, " 2.4.") == NULL);
}
// Can use argv[1] directly, but this will mess up // Can use argv[1] directly, but this will mess up
// parameters as seen by e.g. ps. Making a copy... // parameters as seen by e.g. ps. Making a copy...