When launching installboot on sparc64 with an empty file for the
"prototype code" for the first stage boot program, it leads to a
segmentation fault.

Tested on sparc64 with the lastest snapshot (#163: Wed Nov 17 22:47:15 MST
201)

$ touch /tmp/proto
$ /usr/mdec/installboot /tmp/proto dev
Segmentation fault

Here is a small/stupid patch that fix it:

Index: installboot.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/stand/installboot/installboot.c,v
retrieving revision 1.7
diff -u -r1.7 installboot.c
--- installboot.c       26 Jun 2008 05:42:13 -0000      1.7
+++ installboot.c       18 Nov 2010 23:12:13 -0000
@@ -196,6 +196,9 @@

                if (fstat(protofd, &sb) < 0)
                        err(1, "fstat: %s", proto);
+
+               if (sb.st_size == 0)
+                       errx(1, "%s is empty", proto);

                /* there must be a better way */
                blanklen = DEV_BSIZE - ((sb.st_size + DEV_BSIZE) & (DEV_BSIZE
- 1));


Yes, maybe there is a better way.

eg.

Reply via email to