Bug 126386

Summary: [nanobsd] NANO_MEDIASIZE overflow
Product: Base System Reporter: Mark A <mark>
Component: confAssignee: Antoine Brodin <antoine>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 7.0-RELEASE   
Hardware: Any   
OS: Any   

Description Mark A 2008-08-09 01:00:13 UTC
In /usr/src/tools/tools/nanobsd/FlashDevice.sub there are 2 lines
in question...

            NANO_MEDIASIZE=`expr 4097802240 / 512`
            NANO_MEDIASIZE=`expr 4224761856 / 512`

Those result with...

            expr 4097802240 / 512
            4194303

            expr 4224761856 / 512
            4194303

Fix: 

Use expr -e 

            expr -e 4097802240 / 512
            8003520

            expr -e 4224761856 / 512
            8251488
    
    The man page for expr also states that if EXPR_COMPAT is
    set then expr -e is used.
How-To-Repeat:     Include "FlashDevice Sandisk 4g" in your nanobsd configuration 
    file.
    
    Insert a few debugging print statements in nanobsd.sh where 
    NANO_MEDIASIZE is used. 

    When "/bin/sh nanobsd.sh -c nanobsd.conf" is run $NANO_MEDIASIZE 
    always prints 4194303.
Comment 1 dfilter service freebsd_committer freebsd_triage 2008-08-12 17:59:48 UTC
antoine     2008-08-12 16:59:23 UTC

  FreeBSD src repository

  Modified files:
    tools/tools/nanobsd  FlashDevice.sub 
  Log:
  SVN rev 181631 on 2008-08-12 16:59:23Z by antoine
  
  Use expr -e instead of expr to compute NANO_MEDIASIZE for Flash devices
  larger than 2GB to prevent an overflow [1].
  Make case-insensitive comparison work for siliconsystems, soekris and
  transcend devices.
  
  PR:             conf/126386 [1]
  Submitted by:   Mark A [1]
  MFC after:      1 month
  
  Revision  Changes    Path
  1.9       +5 -5      src/tools/tools/nanobsd/FlashDevice.sub
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 2 Antoine Brodin freebsd_committer freebsd_triage 2008-08-12 18:06:11 UTC
State Changed
From-To: open->patched

Patched in head. 


Comment 3 Antoine Brodin freebsd_committer freebsd_triage 2008-08-12 18:06:11 UTC
Responsible Changed
From-To: freebsd-bugs->antoine

MFC reminder.
Comment 4 Antoine Brodin freebsd_committer freebsd_triage 2009-01-10 09:40:40 UTC
State Changed
From-To: patched->closed

Sam MFCed theses changes to stable/7.