Bug 161045 - 2 * array subscript out of range
2 * array subscript out of range
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: hal (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Zeuthen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-20 04:02 EDT by David Binderman
Modified: 2013-03-05 22:43 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-28 19:49:05 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Binderman 2005-06-20 04:02:31 EDT
Description of problem:

I just tried to compile package hal-0.5.2-2 from Redhat
Fedora Core development tree with a new development version of the
GNU C compiler.

The compiler said

1.

volume_id.c:227: warning: array subscript out of range

The source code is

        __u8 tmp_node[VOLUME_ID_PATH_MAX];

        snprintf(tmp_node, VOLUME_ID_PATH_MAX,
           "/dev/.volume_id-%u-%u-%u", getpid(), major(devt), minor(devt));
        tmp_node[VOLUME_ID_PATH_MAX] = '\0';

Clearly broken code. tmp_node[VOLUME_ID_PATH_MAX] doesn't exist. 
Suggest 

        tmp_node[VOLUME_ID_PATH_MAX - 1] = '\0';

2.

drive_id.c:118: warning: array subscript out of range

The source code is

        __u8 tmp_node[DRIVE_ID_PATH_MAX];

        snprintf(tmp_node, DRIVE_ID_PATH_MAX,
                 "/dev/.drive_id-%u-%u-%u", getpid(), major(devt), minor(devt));
        tmp_node[DRIVE_ID_PATH_MAX] = '\0';

Clearly broken code. tmp_node[DRIVE_ID_PATH_MAX] doesn't exist. 
Suggest 

        tmp_node[DRIVE_ID_PATH_MAX - 1] = '\0';
	


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 David Zeuthen 2006-09-28 19:49:05 EDT
Fixed in 0.5.8.1 as volume_id is no longer part of hal (it comes from the udev
srpm).

Note You need to log in before you can comment on or make changes to this bug.