Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Dec 2015 02:15:12 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292899 - head/sys/boot/forth
Message-ID:  <201512300215.tBU2FCAB076920@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 ;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512300215.tBU2FCAB076920>