Module Name: src Committed By: martin Date: Sat Jun 11 18:27:22 UTC 2022
Modified Files: src/usr.sbin/sysinst: label.c Log Message: Avoid integer arithmetic overflow when checking a partition table without any partitions. Fix some comments. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/sysinst/label.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/label.c diff -u src/usr.sbin/sysinst/label.c:1.35 src/usr.sbin/sysinst/label.c:1.36 --- src/usr.sbin/sysinst/label.c:1.35 Sat Jun 11 15:41:19 2022 +++ src/usr.sbin/sysinst/label.c Sat Jun 11 18:27:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: label.c,v 1.35 2022/06/11 15:41:19 martin Exp $ */ +/* $NetBSD: label.c,v 1.36 2022/06/11 18:27:22 martin Exp $ */ /* * Copyright 1997 Jonathan Stone @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: label.c,v 1.35 2022/06/11 15:41:19 martin Exp $"); +__RCSID("$NetBSD: label.c,v 1.36 2022/06/11 18:27:22 martin Exp $"); #endif #include <sys/types.h> @@ -101,7 +101,7 @@ real_partition(const struct partition_us /* * Check partitioning for overlapping partitions. - * Returns 0 if no overlapping partition found, nonzero otherwise. + * Returns true if no overlapping partition found. * Sets reference arguments ovly1 and ovly2 to the indices of * overlapping partitions if any are found. */ @@ -114,6 +114,9 @@ checklabel(struct disk_partitions *parts daddr_t istart, iend, jstart, jend; unsigned int fs_type, fs_sub_type; + if (parts->num_part == 0) + return true; + for (i = 0; i < parts->num_part - 1; i ++ ) { if (!parts->pscheme->get_part_info(parts, i, &info)) continue;