$NetBSD: patch-af,v 1.1 2000/12/07 14:11:37 is Exp $ --- init.c.orig Fri Mar 19 09:57:59 1999 +++ init.c @@ -27,15 +27,30 @@ */ static int read_boot(Stream_t *Stream, struct bootsector * boot, int size) { + int rc; + char *buf; + + buf = (char *)boot; + /* read the first sector, or part of it */ if(!size) size = BOOTSIZE; - if(size > 1024) - size = 1024; - if (force_read(Stream, (char *) boot, 0, size) != size) - return -1; - return 0; + if (size > sizeof(struct bootsector)) { + buf = malloc(size); + if (!buf) + return(-1); + } + + rc = 0; + if (force_read(Stream, buf, 0, size) != size) + rc = -1; + + if (buf != (char *)boot) { + memcpy(boot, buf, sizeof(struct bootsector)); + free(buf); + } + return rc; } static int fs_flush(Stream_t *Stream)