Sat Jul 17 11:32:50 2021 UTC ()
PR 56310: avoid assert() failures (or crashes) when the runtime addition
of a wedge fails (for whatever reasons).


(martin)
diff -r1.23 -r1.24 src/usr.sbin/sysinst/gpt.c
diff -r1.51 -r1.52 src/usr.sbin/sysinst/partman.c

cvs diff -r1.23 -r1.24 src/usr.sbin/sysinst/gpt.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/gpt.c 2021/01/31 22:45:46 1.23
+++ src/usr.sbin/sysinst/gpt.c 2021/07/17 11:32:50 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gpt.c,v 1.23 2021/01/31 22:45:46 rillig Exp $ */ 1/* $NetBSD: gpt.c,v 1.24 2021/07/17 11:32:50 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 2018 The NetBSD Foundation, Inc. 4 * Copyright 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -1394,28 +1394,31 @@ gpt_get_part_device(const struct disk_pa @@ -1394,28 +1394,31 @@ gpt_get_part_device(const struct disk_pa
1394 for (no = 0; p != NULL && no < id; no++) 1394 for (no = 0; p != NULL && no < id; no++)
1395 p = p->gp_next; 1395 p = p->gp_next;
1396 1396
1397 if (no != id || p == NULL) 1397 if (no != id || p == NULL)
1398 return false; 1398 return false;
1399 1399
1400 if (part) 1400 if (part)
1401 *part = -1; 1401 *part = -1;
1402 1402
1403 if (usage == logical_name && p->gp_label[0] == 0 && p->gp_id[0] == 0) 1403 if (usage == logical_name && p->gp_label[0] == 0 && p->gp_id[0] == 0)
1404 usage = plain_name; 1404 usage = plain_name;
1405 if (usage == plain_name || usage == raw_dev_name) 1405 if (usage == plain_name || usage == raw_dev_name)
1406 life = true; 1406 life = true;
1407 if (!(p->gp_flags & GPEF_WEDGE) && life) 1407 if (!(p->gp_flags & GPEF_WEDGE) && life &&
1408 gpt_add_wedge(arg->disk, p); 1408 !gpt_add_wedge(arg->disk, p)) {
 1409 devname[0] = 0;
 1410 return false;
 1411 }
1409 1412
1410 switch (usage) { 1413 switch (usage) {
1411 case logical_name: 1414 case logical_name:
1412 if (p->gp_label[0] != 0) { 1415 if (p->gp_label[0] != 0) {
1413 escape_spaces(tmpname, p->gp_label); 1416 escape_spaces(tmpname, p->gp_label);
1414 snprintf(devname, max_devname_len, 1417 snprintf(devname, max_devname_len,
1415 "NAME=%s", tmpname); 1418 "NAME=%s", tmpname);
1416 } else { 1419 } else {
1417 snprintf(devname, max_devname_len, 1420 snprintf(devname, max_devname_len,
1418 "NAME=%s", p->gp_id); 1421 "NAME=%s", p->gp_id);
1419 } 1422 }
1420 break; 1423 break;
1421 case plain_name: 1424 case plain_name:

cvs diff -r1.51 -r1.52 src/usr.sbin/sysinst/partman.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/partman.c 2021/01/31 22:45:46 1.51
+++ src/usr.sbin/sysinst/partman.c 2021/07/17 11:32:50 1.52
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: partman.c,v 1.51 2021/01/31 22:45:46 rillig Exp $ */ 1/* $NetBSD: partman.c,v 1.52 2021/07/17 11:32:50 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 2012 Eugene Lozovoy 4 * Copyright 2012 Eugene Lozovoy
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -2837,33 +2837,33 @@ pm_menufmt(menudesc *m, int opt, void *a @@ -2837,33 +2837,33 @@ pm_menufmt(menudesc *m, int opt, void *a
2837 switch (((struct part_entry *)arg)[opt].type) { 2837 switch (((struct part_entry *)arg)[opt].type) {
2838 case PM_DISK: 2838 case PM_DISK:
2839 if (pm_cur->blocked) 2839 if (pm_cur->blocked)
2840 dev_status = msg_string(MSG_pmblocked); 2840 dev_status = msg_string(MSG_pmblocked);
2841 else if (! pm_cur->unsaved) 2841 else if (! pm_cur->unsaved)
2842 dev_status = msg_string(MSG_pmunchanged); 2842 dev_status = msg_string(MSG_pmunchanged);
2843 else 2843 else
2844 dev_status = msg_string(MSG_pmused); 2844 dev_status = msg_string(MSG_pmused);
2845 wprintw(m->mw, "%-43.42s %25.24s", 2845 wprintw(m->mw, "%-43.42s %25.24s",
2846 pm_cur->diskdev_descr, 2846 pm_cur->diskdev_descr,
2847 dev_status); 2847 dev_status);
2848 break; 2848 break;
2849 case PM_PART: 2849 case PM_PART:
2850 if (parts->pscheme->get_part_device != NULL) 2850 if (parts->pscheme->get_part_device == NULL ||
2851 parts->pscheme->get_part_device( 2851 !parts->pscheme->get_part_device(
2852 parts, part_num, 2852 parts, part_num,
2853 dev, sizeof dev, NULL, plain_name, false, 2853 dev, sizeof dev, NULL, plain_name, false,
2854 true); 2854 true))
2855 else 2855 strcpy(dev, "-");
2856 strcpy(dev, "-"); 2856
2857 parts->pscheme->get_part_info(parts, 2857 parts->pscheme->get_part_info(parts,
2858 part_num, &info); 2858 part_num, &info);
2859 if (pm_cur->mounted != NULL && 2859 if (pm_cur->mounted != NULL &&
2860 pm_cur->mounted[part_num] != NULL && 2860 pm_cur->mounted[part_num] != NULL &&
2861 pm_cur->mounted[part_num][0] != 0) 2861 pm_cur->mounted[part_num][0] != 0)
2862 mount_point = msg_string(MSG_pmmounted); 2862 mount_point = msg_string(MSG_pmmounted);
2863 else 2863 else
2864 mount_point = msg_string(MSG_pmunused); 2864 mount_point = msg_string(MSG_pmunused);
2865 fstype = getfslabelname(info.fs_type, 2865 fstype = getfslabelname(info.fs_type,
2866 info.fs_sub_type); 2866 info.fs_sub_type);
2867 if (info.last_mounted != NULL) { 2867 if (info.last_mounted != NULL) {
2868 snprintf(buf, STRSIZE, "%s (%s) %s", 2868 snprintf(buf, STRSIZE, "%s (%s) %s",
2869 info.last_mounted, fstype, 2869 info.last_mounted, fstype,