Hi,

I just realized that bioctl can print its uninitialized memory.  The
function bio_status() prints information from a struct basically after
each ioctl().  The BIOCLOCATE ioctl() though never sets this in the
struct.  Thus each BIOCLOCATE ioctl() keeps the struct in the state
as it has been before.

There are two cases where bioctl calls bio_status() after a BIOCLOCATE.
In one case the struct is zeroed before, in the other it isn't.

I propose removing the prints after the BIOLOCATEs to not make anyone
believe there should actually be a status print.  Additionally I'd like
to add a memset in the one case where there's none.

ok?

Patrick

diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c
index aad5b965d669..ace216fc55cb 100644
--- a/sbin/bioctl/bioctl.c
+++ b/sbin/bioctl/bioctl.c
@@ -231,13 +231,12 @@ main(int argc, char *argv[])
                if (devh == -1)
                        err(1, "Can't open %s", "/dev/bio");
 
+               memset(&bl, 0, sizeof(bl));
                bl.bl_name = devicename;
                if (ioctl(devh, BIOCLOCATE, &bl))
                        errx(1, "Can't locate %s device via %s",
                            bl.bl_name, "/dev/bio");
 
-               bio_status(&bl.bl_bio.bio_status);
-
                bio_cookie = bl.bl_bio.bio_cookie;
                biodev = 1;
                devicename = NULL;
@@ -805,8 +804,6 @@ bio_blink(char *enclosure, int target, int blinktype)
        bl.bl_name = enclosure;
        if (ioctl(bioh, BIOCLOCATE, &bl))
                errx(1, "Can't locate %s device via %s", enclosure, "/dev/bio");
- 
-       bio_status(&bl.bl_bio.bio_status);
 
        memset(&blink, 0, sizeof(blink));
        blink.bb_bio.bio_cookie = bio_cookie;

Reply via email to