Author: ae
Date: Tue Jun 28 05:04:31 2011
New Revision: 223619
URL: http://svn.freebsd.org/changeset/base/223619

Log:
  MFC r223364:
    When user specifies the bootcode with size smaller than VTOC_BOOTSIZE,
    gpart_write_partcode_vtoc8 does access out of range of allocated memory.
    Check size of bootcode before writing it.
  
    Pointed out by:     ru

Modified:
  stable/7/sbin/geom/class/part/geom_part.c
Directory Properties:
  stable/7/sbin/geom/class/part/   (props changed)

Modified: stable/7/sbin/geom/class/part/geom_part.c
==============================================================================
--- stable/7/sbin/geom/class/part/geom_part.c   Tue Jun 28 04:57:53 2011        
(r223618)
+++ stable/7/sbin/geom/class/part/geom_part.c   Tue Jun 28 05:04:31 2011        
(r223619)
@@ -576,8 +576,11 @@ gpart_bootcode(struct gctl_req *req, uns
                        if (idx == 0)
                                errx(EXIT_FAILURE, "missing -i option");
                        gpart_write_partcode(gp, idx, partcode, partsize);
-               } else
+               } else {
+                       if (partsize != VTOC_BOOTSIZE)
+                               errx(EXIT_FAILURE, "invalid bootcode");
                        gpart_write_partcode_vtoc8(gp, idx, partcode);
+               }
        } else
                if (bootcode == NULL)
                        errx(EXIT_FAILURE, "no -b nor -p");
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to