Bug 161045

Summary: 2 * array subscript out of range
Product: [Fedora] Fedora Reporter: David Binderman <dcb314>
Component: halAssignee: David Zeuthen <davidz>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: mclasen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-09-28 23:49:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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).