Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 161045 - 2 * array subscript out of range
Summary: 2 * array subscript out of range
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: hal
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: David Zeuthen
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-06-20 08:02 UTC by David Binderman
Modified: 2013-03-06 03:43 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-28 23:49:05 UTC


Attachments (Terms of Use)

Description David Binderman 2005-06-20 08:02:31 UTC
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 23:49:05 UTC
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.