diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2021-08-01 03:14:05 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2021-08-01 03:14:05 +0000 |
commit | bfbefdf2d9aa12107d08d796d6fc78862ab85402 (patch) | |
tree | 76d31932b03f8a71a1432e0b053f1d5ee4ca78e9 /lib/sg_cmds_extra.c | |
parent | c2a103b26a80218c8c2ee9a8ddb7122e36a69331 (diff) | |
download | sg3_utils-bfbefdf2d9aa12107d08d796d6fc78862ab85402.tar.gz |
sg_ses: fix crash when 'm LEN' < 252
Cleanups suggested cppcheck
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@907 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib/sg_cmds_extra.c')
-rw-r--r-- | lib/sg_cmds_extra.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c index 7874dd16..e55e8075 100644 --- a/lib/sg_cmds_extra.c +++ b/lib/sg_cmds_extra.c @@ -1203,12 +1203,13 @@ static bool has_blk_ili(uint8_t * sensep, int sb_len) { int resp_code; - const uint8_t * cup; if (sb_len < 8) return false; resp_code = (0x7f & sensep[0]); if (resp_code >= 0x72) { /* descriptor format */ + const uint8_t * cup; + /* find block command descriptor */ if ((cup = sg_scsi_sense_desc_find(sensep, sb_len, 0x5))) return (cup[3] & 0x20); @@ -1567,7 +1568,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk, int vb) { static const char * const cdb_s = "verify(10)"; - int k, res, ret, s_cat, slen; + int res, ret, s_cat, slen; uint8_t v_cdb[VERIFY10_CMDLEN] = {VERIFY10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t sense_b[SENSE_BUFF_LEN]; @@ -1586,7 +1587,8 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk, sg_get_command_str(v_cdb, VERIFY10_CMDLEN, false, sizeof(b), b)); if ((vb > 3) && bytchk && data_out && (data_out_len > 0)) { - k = data_out_len > 4104 ? 4104 : data_out_len; + int k = data_out_len > 4104 ? 4104 : data_out_len; + pr2ws(" data_out buffer%s\n", (data_out_len > 4104 ? ", first 4104 bytes" : "")); hex2stderr((const uint8_t *)data_out, k, vb < 5); @@ -1644,7 +1646,7 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba, int data_out_len, uint64_t * infop, bool noisy, int vb) { static const char * const cdb_s = "verify(16)"; - int k, res, ret, s_cat, slen; + int res, ret, s_cat, slen; uint8_t v_cdb[VERIFY16_CMDLEN] = {VERIFY16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t sense_b[SENSE_BUFF_LEN]; @@ -1664,7 +1666,8 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba, sg_get_command_str(v_cdb, VERIFY16_CMDLEN, false, sizeof(b), b)); if ((vb > 3) && bytchk && data_out && (data_out_len > 0)) { - k = data_out_len > 4104 ? 4104 : data_out_len; + int k = data_out_len > 4104 ? 4104 : data_out_len; + pr2ws(" data_out buffer%s\n", (data_out_len > 4104 ? ", first 4104 bytes" : "")); hex2stderr((const uint8_t *)data_out, k, vb < 5); |