summaryrefslogtreecommitdiffstats
path: root/sys/boot/forth
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2015-12-30 02:15:12 +0000
committerdteske <dteske@FreeBSD.org>2015-12-30 02:15:12 +0000
commit73e30cf409d29ddc9d5d5fcf1cd8f70440a2f81c (patch)
tree3dddb7a6efb987dd39bac31ebf54b20f27e385ae /sys/boot/forth
parentf051dcad0775edede26c36c576146167f312243b (diff)
downloadFreeBSD-src-73e30cf409d29ddc9d5d5fcf1cd8f70440a2f81c.zip
FreeBSD-src-73e30cf409d29ddc9d5d5fcf1cd8f70440a2f81c.tar.gz
Fix stack leak introduced by SVN r97201 (nextboot_conf support).
Fix erroneous error path in error messages when processing boot_conf. Fixup stack comments for functions introduced by SVN r97201. Remove a questioning stack comment introduced by SVN r186789. NB: Comment removed because strdup usage here is correct/not a leak. MFC after: 1 week
Diffstat (limited to 'sys/boot/forth')
-rw-r--r--sys/boot/forth/support.4th14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th
index 08f5004..9a68872 100644
--- a/sys/boot/forth/support.4th
+++ b/sys/boot/forth/support.4th
@@ -833,7 +833,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- )
repeat
;
-: peek_file
+: peek_file ( addr len -- )
0 to end_of_file?
reset_line_reading
O_RDONLY fopen fd !
@@ -844,6 +844,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- )
['] process_assignment catch
['] free_buffers catch
fd @ fclose
+ swap throw throw
;
only forth also support-functions definitions
@@ -1021,25 +1022,26 @@ string current_file_name_ref \ used to print the file name
;
: get_nextboot_conf_file ( -- addr len )
- nextboot_conf_file strget strdup \ XXX is the strdup a leak ?
+ nextboot_conf_file strget strdup
;
: rewrite_nextboot_file ( -- )
get_nextboot_conf_file
O_WRONLY fopen fd !
fd @ -1 = if EOPEN throw then
- fd @ s' nextboot_enable="NO" ' fwrite
+ fd @ s' nextboot_enable="NO" ' fwrite ( fd buf len -- nwritten ) drop
fd @ fclose
;
-: include_nextboot_file
+: include_nextboot_file ( -- )
get_nextboot_conf_file
- ['] peek_file catch
+ ['] peek_file catch if 2drop then
nextboot? if
get_nextboot_conf_file
+ current_file_name_ref strref
['] load_conf catch
process_conf_errors
- ['] rewrite_nextboot_file catch
+ ['] rewrite_nextboot_file catch if 2drop then
then
;
OpenPOWER on IntegriCloud