Index: usr.sbin/sesutil/sesutil.c =================================================================== --- usr.sbin/sesutil/sesutil.c +++ usr.sbin/sesutil/sesutil.c @@ -570,17 +570,17 @@ { char ident[DISK_IDENT_SIZE]; struct diocgattr_arg arg; - char *device, *tmp; + char *tmp; off_t mediasize; + int comma; int fd; - tmp = strdup(devnames); + comma = (int)strcspn(devnames, ","); + asprintf(&tmp, "/dev/%.*s", comma, devnames); if (tmp == NULL) - err(1, "strdup"); - - device = strsep(&tmp, ","); - asprintf(&tmp, "/dev/%s", device); + err(1, "asprintf"); fd = open(tmp, O_RDONLY); + free(tmp); if (fd < 0) { /* * This can happen with a disk so broken it cannot @@ -589,6 +589,7 @@ *model = strdup("?"); *serial = strdup("?"); *size = -1; + close(fd); return; } @@ -608,6 +609,7 @@ *size = mediasize; else *size = -1; + close(fd); } static void