summaryrefslogtreecommitdiff
path: root/sysutils/mtools/patches/patch-af
blob: 563ca9ecf0561f889157b847f5f0509aab479d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$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)