Bug 110816 - bad source code
bad source code
Product: Fedora
Classification: Fedora
Component: gphoto2 (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Depends On:
  Show dependency treegraph
Reported: 2003-11-24 11:51 EST by d.binderman
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-11-27 12:28:14 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description d.binderman 2003-11-24 11:51:22 EST
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

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

How reproducible:

Steps to Reproduce:
1. by inspection

Additional info:
Comment 1 Tim Waugh 2003-11-27 04:53:09 EST
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 05:01:20 EST
>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 12:28:14 EST
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 14:38:24 EST
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.