From 29f3f095a624492078f7578be83d684fc32fb2a9 Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Tue, 1 Apr 2003 14:44:53 +0000 Subject: [PATCH] Don't die of SIGSEGV on a missing fstype field in a saved disklabel file. MFC after: 1 week --- sbin/bsdlabel/bsdlabel.c | 4 ++++ sbin/disklabel/disklabel.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c index 49ada3cab60f..a6477fad6a8f 100644 --- a/sbin/bsdlabel/bsdlabel.c +++ b/sbin/bsdlabel/bsdlabel.c @@ -1134,6 +1134,10 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno) return (1); } pp->p_offset = v; + if (tp == NULL) { + fprintf(stderr, "line %d: missing file system type\n", lineno); + return (1); + } cp = tp, tp = word(cp); for (cpp = fstypenames; cpp < &fstypenames[FSMAXTYPES]; cpp++) if (*cpp && streq(*cpp, cp)) diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 49ada3cab60f..a6477fad6a8f 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1134,6 +1134,10 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno) return (1); } pp->p_offset = v; + if (tp == NULL) { + fprintf(stderr, "line %d: missing file system type\n", lineno); + return (1); + } cp = tp, tp = word(cp); for (cpp = fstypenames; cpp < &fstypenames[FSMAXTYPES]; cpp++) if (*cpp && streq(*cpp, cp))