Bug 110816 - bad source code
Summary: bad source code
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gphoto2
Version: 1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-11-24 16:51 UTC by d.binderman
Modified: 2007-11-30 22:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-11-27 17:28:14 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description d.binderman 2003-11-24 16:51:22 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)

Description of problem:

I just tried to compile package gphoto2-2_1_2-1 from Fedora.

The compiler said

casio-qv-commands.c(210): warning #175: subscript out of range

The source code is

int
QVsetspeed (Camera *camera, QVSpeed speed)
{
        unsigned char cmd[3];

        cmd[0] = 'C';
        cmd[1] = 'B';
        cmd[3] = (unsigned char) speed;
        CR (QVsend (camera, cmd, 3, NULL, 0));

        return (GP_OK);
}

This code is clearly wrong, by inspection. Suggest change line to

        cmd[ 2] = (unsigned char) speed;


Version-Release number of selected component (if applicable):
gphoto2-2_1_2-1 

How reproducible:
Always

Steps to Reproduce:
1. by inspection
2.
3.
    

Additional info:

Comment 1 Tim Waugh 2003-11-27 09:53:09 UTC
It is far from clear that this is wrong.

(Please report these kind of bugs upstream where possible; thanks.)

Comment 2 d.binderman 2003-11-27 10:01:20 UTC
>It is far from clear that this is wrong.

Let me be more clear.

unsigned char cmd[3];
cmd[3] = (unsigned char) speed;

Array bounds in C are exclusive. cmd[ 3] is not available.

>(Please report these kind of bugs upstream where possible; thanks.)

I've tried that - it didn't work. 

Would it be possible for you to report this bug for me, please ?







Comment 3 Tim Waugh 2003-11-27 17:28:14 UTC
Oh I see what you mean.  Your correction might well be wrong though,
and it isn't clear whether the array should be larger or the values
squashed together.

I've reported it upstream.

Comment 4 David Binderman 2004-11-05 19:38:24 UTC
I can confirm that this bug still exists in Fedora Core 3
Test 3.

It hasn't been fixed in nearly a year.



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