Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst PR 56893: fix input validation when the use...
details: https://anonhg.NetBSD.org/src/rev/fa5bf68e4549
branches: trunk
changeset: 367264:fa5bf68e4549
user: martin <martin%NetBSD.org@localhost>
date: Mon Jun 20 16:06:38 2022 +0000
description:
PR 56893: fix input validation when the user moves a new partition to
a totaly different part of the disk. Fix size handling for freshly
added partitions (which would previously use random stack data due to
bogus error checking).
diffstat:
usr.sbin/sysinst/label.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diffs (57 lines):
diff -r e3d9525bbff1 -r fa5bf68e4549 usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c Mon Jun 20 15:40:24 2022 +0000
+++ b/usr.sbin/sysinst/label.c Mon Jun 20 16:06:38 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.38 2022/06/19 12:08:31 martin Exp $ */
+/* $NetBSD: label.c,v 1.39 2022/06/20 16:06:38 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.38 2022/06/19 12:08:31 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.39 2022/06/20 16:06:38 martin Exp $");
#endif
#include <sys/types.h>
@@ -261,14 +261,18 @@
start = getpartoff(edit->pset->parts, edit->info.start);
if (edit->info.size != 0) {
- /* Try to keep end in the same place */
- end = edit->info.start + edit->info.size;
- if (end < start)
- edit->info.size = edit->pset->parts->pscheme->
- max_free_space_at(edit->pset->parts,
- edit->info.start);
- else
- edit->info.size = end - start;
+ if (start < (edit->info.start+edit->info.size)) {
+ /* Try to keep end in the same place */
+ end = edit->info.start + edit->info.size;
+ if (end < start)
+ edit->info.size = edit->pset->parts->pscheme->
+ max_free_space_at(edit->pset->parts,
+ edit->info.start);
+ else
+ edit->info.size = end - start;
+ } else {
+ edit->info.size = 0;
+ }
}
edit->info.start = start;
return 0;
@@ -282,8 +286,9 @@
daddr_t size;
/* get original partition data, in case start moved already */
- edit->pset->parts->pscheme->get_part_info(edit->pset->parts,
- edit->id, &pinfo);
+ if (!edit->pset->parts->pscheme->get_part_info(edit->pset->parts,
+ edit->id, &pinfo))
+ pinfo = edit->info;
/* ask for new size with old start and current values */
size = getpartsize(edit->pset->parts, pinfo.start,
edit->info.start, edit->info.size);
- Prev by Date:
[src/trunk]: src/sys/arch/x86/x86 Add tdx_guest, brs, hfi, ibt, amx_bf16, amx...
- Next by Date:
[src/trunk]: src/usr.sbin/sysinst When the user aborts the target disk select...
- Previous by Thread:
[src/trunk]: src/sys/arch/x86/x86 Add tdx_guest, brs, hfi, ibt, amx_bf16, amx...
- Next by Thread:
[src/trunk]: src/usr.sbin/sysinst When the user aborts the target disk select...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index