Bug 151488 - micq-0.5.0.4-3:array subscript out of range
Summary: micq-0.5.0.4-3:array subscript out of range
Status: RESOLVED FIXED
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: unspecified
Hardware: All SuSE Linux 10.1
: P2 - High : Minor
Target Milestone: ---
Assignee: Stefan Dirsch
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-16 13:42 UTC by David Binderman
Modified: 2006-02-17 09:28 UTC (History)
0 users

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Fixes for macros (733 bytes, patch)
2006-02-17 09:26 UTC, Stefan Dirsch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2006-02-16 13:42:19 UTC
I just tried to compile package micq-0.5.0.4-3 with the Intel C 
compiler.

It said

contact.c(1240): warning #175: subscript out of range

The source code is

    else if (HAS_CAP (cont->caps, CAP_TRILL_CRYPT | CAP_TRILL_2))

but

#define HAS_CAP(caps,cap) (((caps)[cap / 32]) & (1UL << (cap % 32)))

and CAP_TRILL_CRYPT has the value 18 and the CAP_TRILL_2 has a value of 19.
So making the macro subsitution

    else if (((cont->caps)[ CAP_TRILL_CRYPT | CAP_TRILL_2 / 32]) & (1UL << (CAP_TRILL_CRYPT | CAP_TRILL_2 % 32)))

I just checked the C precedence table. Both / and % are higher than | so the
macro expansion is the same as

    else if (((cont->caps)[ CAP_TRILL_CRYPT | (CAP_TRILL_2 / 32)]) & (1UL << (CAP_TRILL_CRYPT | (CAP_TRILL_2 % 32))))

hence the compiler complaining. Suggest modify the macro definition

#define HAS_CAP(caps,cap) (((caps)[(cap) / 32]) & (1UL << ((cap) % 32)))

Note the extra () around the uses of cap to ensure correct evaluation.
Comment 1 Stefan Dirsch 2006-02-17 09:08:39 UTC
Good catch! Good explanation! I'll fix this. Thanks a lot!
Comment 2 Stefan Dirsch 2006-02-17 09:26:07 UTC
Created attachment 68968 [details]
Fixes for macros
Comment 3 Stefan Dirsch 2006-02-17 09:28:34 UTC
fixed for 10.1 Beta > 4.