rtemsbsd/rc_conf: Fixed non-nullterminated string causing crashes

This commit is contained in:
Aaron Nyholm 2023-03-17 15:10:04 +11:00 committed by Chris Johns
parent 1aa4cb8568
commit 16be3a7c7d

View File

@ -869,7 +869,7 @@ rtems_bsd_run_rc_conf(const char* name, int timeout, bool verbose)
if (r < 0)
return r;
rc_conf = malloc(sb.st_size);
rc_conf = malloc(sb.st_size + 1);
if (rc_conf == NULL) {
errno = ENOMEM;
return -1;
@ -892,6 +892,8 @@ rtems_bsd_run_rc_conf(const char* name, int timeout, bool verbose)
fclose(file);
rc_conf[sb.st_size] = '\0';
r = rtems_bsd_run_rc_conf_script(name, rc_conf, timeout, verbose);
free(rc_conf);