Module Name:    src
Committed By:   martin
Date:           Sun Jun 23 11:47:08 UTC 2019

Modified Files:
        src/usr.sbin/sysinst: gpt.c

Log Message:
Ignore corrupt GPTs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.1 src/usr.sbin/sysinst/gpt.c:1.2
--- src/usr.sbin/sysinst/gpt.c:1.1	Wed Jun 12 06:20:17 2019
+++ src/usr.sbin/sysinst/gpt.c	Sun Jun 23 11:47:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.c,v 1.1 2019/06/12 06:20:17 martin Exp $	*/
+/*	$NetBSD: gpt.c,v 1.2 2019/06/23 11:47:08 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -334,6 +334,12 @@ gpt_read_from_disk(const char *dev, dadd
 	}
 	free(textbuf);
 
+	/* If the GPT was not complete (e.g. truncated image), barf */
+	if (disk_size <= 0) {
+		free(parts);
+		return NULL;
+	}
+
 	parts->dp.pscheme = &gpt_parts;
 	parts->dp.disk = dev;
 	parts->dp.disk_start = start;

Reply via email to