Project

General

Profile

Actions

Bug #13587

closed

stmf_sbd: array subscript 8 is above array bounds

Added by Toomas Soome about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
comstar - iSCSI/FC/SAS target
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Build errors with gcc 10:

    ../../common/io/comstar/lu/stmf_sbd/sbd.c: In function 'sbd_modify_lu':
    ../../common/io/comstar/lu/stmf_sbd/sbd.c:2684:15: error: array subscript 8 is above array bounds
    of 'char[8]' [-Werror=array-bounds]
     2684 |   mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0;
          |   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from ../../common/io/comstar/lu/stmf_sbd/sbd.c:49:
    ../../common/sys/stmf_sbd_ioctl.h:176:8: note: while referencing 'mlu_buf'
      176 |  char  mlu_buf[8]; /* can be more than 8 */
          |        ^~~~~~~
    ../../common/io/comstar/lu/stmf_sbd/sbd.c: In function 'sbd_set_global_props':
    ../../common/io/comstar/lu/stmf_sbd/sbd.c:2911:15: error: array subscript 8 is above array bounds
    of 'char[8]' [-Werror=array-bounds]
     2911 |   mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0;
          |   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from ../../common/io/comstar/lu/stmf_sbd/sbd.c:49:
    ../../common/sys/stmf_sbd_ioctl.h:138:8: note: while referencing 'mlu_buf'
      138 |  char  mlu_buf[8]; /* likely more than 8 */
          |        ^~~~~~~
    cc1: all warnings being treated as errors

gcc really oes not like us, when we have fixed size array and attempt to access it past array end...

Actions #1

Updated by Electric Monk about 1 year ago

  • Gerrit CR set to 1290
Actions #2

Updated by Electric Monk about 1 year ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

git commit d464f34577edaa31dd6978ec04d66a57529dd2c8

commit  d464f34577edaa31dd6978ec04d66a57529dd2c8
Author: Toomas Soome <tsoome@me.com>
Date:   2021-03-10T08:16:02.000Z

    13587 stmf_sbd: array subscript 8 is above array bounds
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF