From cbde70fafd0ab9353e79b708621adf73420fdded Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Wed, 4 Aug 2021 15:35:26 +0000 Subject: sg_ses: guard against small '--maxlen=' values In several utilities guard against '--maxlen=' < 4 or < 16 as they seem to serve no useful purpose other than finding awkward corner cases that may trip up these utilities. git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@908 6180dd3e-e324-4e3e-922d-17de1ae2f315 --- src/sg_get_elem_status.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/sg_get_elem_status.c') diff --git a/src/sg_get_elem_status.c b/src/sg_get_elem_status.c index db7181f2..389a3792 100644 --- a/src/sg_get_elem_status.c +++ b/src/sg_get_elem_status.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Douglas Gilbert. + * Copyright (c) 2019-2021 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -37,7 +37,7 @@ * given SCSI device. */ -static const char * version_str = "1.03 20200423"; /* sbc4r19 */ +static const char * version_str = "1.04 20210803"; /* sbc4r19 */ #ifndef UINT32_MAX @@ -49,6 +49,7 @@ static const char * version_str = "1.03 20200423"; /* sbc4r19 */ #define MAX_GPES_BUFF_LEN ((1024 * 1024) + DEF_GPES_BUFF_LEN) #define GPES_DESC_OFFSET 32 /* descriptors starts at this byte offset */ #define GPES_DESC_LEN 32 +#define MIN_MAXLEN 16 #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define DEF_PT_TIMEOUT 60 /* 60 seconds */ @@ -291,6 +292,11 @@ main(int argc, char * argv[]) } if (0 == maxlen) maxlen = DEF_GPES_BUFF_LEN; + else if (n < MIN_MAXLEN) { + pr2serr("Warning: --maxlen=LEN less than %d ignored\n", + MIN_MAXLEN); + maxlen = DEF_GPES_BUFF_LEN; + } break; case 'r': do_raw = true; -- cgit v1.2.3