mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-01 23:33:05 +08:00
rtemsbsd/rc_conf: Fixed non-nullterminated string causing crashes
This commit is contained in:
parent
1aa4cb8568
commit
16be3a7c7d
@ -869,7 +869,7 @@ rtems_bsd_run_rc_conf(const char* name, int timeout, bool verbose)
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
rc_conf = malloc(sb.st_size);
|
rc_conf = malloc(sb.st_size + 1);
|
||||||
if (rc_conf == NULL) {
|
if (rc_conf == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
@ -892,6 +892,8 @@ rtems_bsd_run_rc_conf(const char* name, int timeout, bool verbose)
|
|||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
|
rc_conf[sb.st_size] = '\0';
|
||||||
|
|
||||||
r = rtems_bsd_run_rc_conf_script(name, rc_conf, timeout, verbose);
|
r = rtems_bsd_run_rc_conf_script(name, rc_conf, timeout, verbose);
|
||||||
|
|
||||||
free(rc_conf);
|
free(rc_conf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user