summaryrefslogtreecommitdiffstats
path: root/usr.sbin/fstyp/fstyp.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-08-02 10:08:57 +0000
committertrasz <trasz@FreeBSD.org>2015-08-02 10:08:57 +0000
commit75c063e8b8ed27522de533ba24a98e50a29617e6 (patch)
treefdfa2cf5f8ca6dda97dd9a21a4b61ec291b9e26e /usr.sbin/fstyp/fstyp.c
parent529945ff14626dc8dc217b57e92818e9ab7e55f3 (diff)
downloadFreeBSD-src-75c063e8b8ed27522de533ba24a98e50a29617e6.zip
FreeBSD-src-75c063e8b8ed27522de533ba24a98e50a29617e6.tar.gz
MFC r284582:
Fix off-by-one error in fstyp(8) and geom_label(4) that made them use a single space (" ") as a CD9660 label name when no label was present. Similar problem was also present in msdosfs label recognition. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/fstyp/fstyp.c')
-rw-r--r--usr.sbin/fstyp/fstyp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c
index b3bdcde..b49eb1e 100644
--- a/usr.sbin/fstyp/fstyp.c
+++ b/usr.sbin/fstyp/fstyp.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -104,6 +105,21 @@ checked_strdup(const char *s)
return (c);
}
+void
+rtrim(char *label, size_t size)
+{
+ ptrdiff_t i;
+
+ for (i = size - 1; i >= 0; i--) {
+ if (label[i] == '\0')
+ continue;
+ else if (label[i] == ' ')
+ label[i] = '\0';
+ else
+ break;
+ }
+}
+
static void
usage(void)
{
OpenPOWER on IntegriCloud