NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/57856: blkdiscard abort()s when not supplying a partition name
>Number: 57856
>Category: bin
>Synopsis: blkdiscard abort()s when not supplying a partition name
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jan 14 18:25:00 +0000 2024
>Originator: M. Boerschig
>Release: NetBSD 10.0_RC2
>Organization:
>Environment:
NetBSD 10.0_RC2 (GENERIC) amd64
>Description:
Not sure if this is worth a PR, but blkdiscard abort()ed on me during sysinstall. I tried to blkdiscard my nvme (like I'm used to on Linux) before install. However, it took some experimenting to get the arguments right and it aborted.
The patch attached removes the assert() and replaces it with a error message -- not sure if this is helpful. I just don't like Release software to dump core on user input...
Also, discard seems to be not supported on NVME, but I'll have a look separately.
>How-To-Repeat:
$ blkdiscard /dev/ld0
assertion "partchar >= 'a' && partchar <= 'p'" failed: file "/usr/src/sbin/blkdiscard/blkdiscard.c", line 190, function "main"
Abort (core dumped)
>Fix:
diff --git a/sbin/blkdiscard/blkdiscard.c b/sbin/blkdiscard/blkdiscard.c
index 7bccd3f6e128..886181f7b993 100644
--- a/sbin/blkdiscard/blkdiscard.c
+++ b/sbin/blkdiscard/blkdiscard.c
@@ -45,7 +45,6 @@
#include <unistd.h>
#include <err.h>
#include <errno.h>
-#include <assert.h>
#include <stdbool.h>
static bool secure = false;
@@ -187,7 +186,10 @@ main(int argc, char *argv[])
struct disklabel dl;
if (ioctl(fd, DIOCGDINFO, &dl) != -1) {
char partchar = name[strlen(name)-1];
- assert(partchar >= 'a' && partchar <= 'p');
+ if(!(partchar >= 'a' && partchar <= 'p')) {
+ errx(1, "%s: the partition suffix '%c' is not valid. "
+ "Expected range is [a-p].", name, partchar);
+ }
int part = partchar - 'a';
size = (uint64_t)dl.d_partitions[part].p_size *
Home |
Main Index |
Thread Index |
Old Index