svn commit: r292899 - head/sys/boot/forth
Devin Teske
dteske at FreeBSD.org
Wed Dec 30 02:15:14 UTC 2015
Author: dteske
Date: Wed Dec 30 02:15:12 2015
New Revision: 292899
URL: https://svnweb.freebsd.org/changeset/base/292899
Log:
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
Modified:
head/sys/boot/forth/support.4th
Modified: head/sys/boot/forth/support.4th
==============================================================================
--- head/sys/boot/forth/support.4th Wed Dec 30 01:02:22 2015 (r292898)
+++ head/sys/boot/forth/support.4th Wed Dec 30 02:15:12 2015 (r292899)
@@ -833,7 +833,7 @@ get-current ( -- wid ) previous definiti
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 definiti
['] 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 p
;
: 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
;
More information about the svn-src-head
mailing list