From a96dd72561007f315dbda98c8e06047f89f9ac50 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 29 May 2014 08:26:47 +0200 Subject: [PATCH] installer: Fix disk_find() on systems that have both da1 and da10. In addition to comparing names (up to the length of the disk which was found previously), also compare name lengths. While here, remove the disk_find() check in disk_new(). disk_new() didn't deal with it returning NULL. But because the list of disks we offer as targets for installing is taken from sysctl kern.disks' output, it will not have duplicates (else it would likely be a bug in the kernel). Reported-by: BSDUX on IRC --- usr.sbin/installer/libinstaller/diskutil.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/usr.sbin/installer/libinstaller/diskutil.c b/usr.sbin/installer/libinstaller/diskutil.c index 82fa689762..2ca75c595e 100644 --- a/usr.sbin/installer/libinstaller/diskutil.c +++ b/usr.sbin/installer/libinstaller/diskutil.c @@ -153,11 +153,6 @@ disk_new(struct storage *s, const char *dev_name) { struct disk *d; - if (disk_find(s, dev_name) != NULL) { - /* Already discovered */ - return(NULL); - } - AURA_MALLOC(d, disk); d->device = aura_strdup(dev_name); @@ -275,7 +270,8 @@ disk_find(const struct storage *s, const char *device) struct disk *d = s->disk_head; while (d != NULL) { - if (strncmp(device, d->device, strlen(d->device)) == 0) + if (strncmp(device, d->device, strlen(d->device)) == 0 && + strlen(device) == strlen(d->device)) return(d); d = d->next; } -- 2.41.0