From a0193349a585086d70c9ec3dda5b2da5126835d4 Mon Sep 17 00:00:00 2001 From: krw Date: Sun, 26 Mar 2023 16:23:58 +0000 Subject: [PATCH] Pass lbuf/lbuflen to PRT_print_[mbr|gpt]_menu() to allow changes to the original input. Just zap it for now. No functional change. --- sbin/fdisk/cmd.c | 12 +++++++----- sbin/fdisk/part.c | 10 +++++++--- sbin/fdisk/part.h | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 08dd2b1f106..4a263772787 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.169 2023/03/25 15:58:44 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.170 2023/03/26 16:23:58 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -574,8 +574,9 @@ ask_pid(const int dflt) if (strlen(lbuf) == 0) return dflt; if (strcmp(lbuf, "?") == 0) { - PRT_print_mbrmenu(); - continue; + PRT_print_mbrmenu(lbuf, sizeof(lbuf)); + if (strlen(lbuf) == 0) + continue; } num = hex_octet(lbuf); @@ -620,8 +621,9 @@ ask_uuid(const struct uuid *olduuid) string_from_line(lbuf, sizeof(lbuf), TRIMMED); if (strcmp(lbuf, "?") == 0) { - PRT_print_gptmenu(); - continue; + PRT_print_gptmenu(lbuf, sizeof(lbuf)); + if (strlen(lbuf) == 0) + continue; } else if (strlen(lbuf) == 0) { uuid = *olduuid; goto done; diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index b4e687c4b14..03702bed66a 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.138 2023/03/26 13:12:33 krw Exp $ */ +/* $OpenBSD: part.c,v 1.139 2023/03/26 16:23:58 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -311,7 +311,7 @@ PRT_protected_guid(const struct uuid *uuid) } void -PRT_print_mbrmenu(void) +PRT_print_mbrmenu(char *lbuf, size_t lbuflen) { unsigned int cidx, i, idrows; @@ -328,10 +328,12 @@ PRT_print_mbrmenu(void) mbr_types[cidx].mt_name); printf("\n"); } + + memset(lbuf, 0, lbuflen); /* Just continue. */ } void -PRT_print_gptmenu(void) +PRT_print_gptmenu(char *lbuf, size_t lbuflen) { unsigned int cidx, i, idrows; @@ -348,6 +350,8 @@ PRT_print_gptmenu(void) gpt_types[cidx].gt_name); printf("\n"); } + + memset(lbuf, 0, lbuflen); /* Just continue. */ } void diff --git a/sbin/fdisk/part.h b/sbin/fdisk/part.h index ae624a93890..7f2d114b044 100644 --- a/sbin/fdisk/part.h +++ b/sbin/fdisk/part.h @@ -1,4 +1,4 @@ -/* $OpenBSD: part.h,v 1.40 2023/03/25 15:58:44 krw Exp $ */ +/* $OpenBSD: part.h,v 1.41 2023/03/26 16:23:58 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -29,8 +29,8 @@ struct prt { unsigned char prt_id; }; -void PRT_print_mbrmenu(void); -void PRT_print_gptmenu(void); +void PRT_print_mbrmenu(char *, size_t); +void PRT_print_gptmenu(char *, size_t); void PRT_parse(const struct dos_partition *, const uint64_t, const uint64_t, struct prt *); void PRT_make(const struct prt *,const uint64_t, const uint64_t, -- 2.20.1