From cfd8e6ef491a7a5ff900ba2ba3deff7d0bebb0a6 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Fri, 15 Sep 2017 15:47:07 +0200 Subject: attr: Fix segmentation fault When the -V option is used without -s, attr will cause a segmentation fault instead of reporting an error: $ touch somefile $ attr -V whatever somefile Segmentation fault (core dumped) https://savannah.nongnu.org/bugs/?48244 --- tools/attr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/attr.c b/tools/attr.c index d68a62c..c8aa0b4 100644 --- a/tools/attr.c +++ b/tools/attr.c @@ -157,6 +157,10 @@ main(int argc, char **argv) */ switch (opflag) { case SETOP: + if (!attrname) { + fprintf(stderr, _("-V only allowed with -s\n")); + usage(); + } if (attrvalue == NULL) { attrvalue = malloc(ATTR_MAX_VALUELEN); if (attrvalue == NULL) { -- cgit v1.2.1