After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783788 - Array limits not properly checked
Array limits not properly checked
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-06-14 14:33 UTC by dcb
Modified: 2017-07-02 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
profile-migrator: Check limit before dereferencing (973 bytes, patch)
2017-07-02 17:00 UTC, Michael Catanzaro
committed Details | Review
notebook: Check limit before dereferencing (852 bytes, patch)
2017-07-02 17:00 UTC, Michael Catanzaro
committed Details | Review

Description dcb 2017-06-14 14:33:56 UTC
1.

../src/profile-migrator/ephy-profile-migrator.c:579]: (style) Array index 'i' is used before limits check.

Source code is

  for (i = 0; locales[i] && i < *best_match; i++) {

2.

    for (i = 0; uris[i] != NULL && i < INSANE_NUMBER_OF_URLS; i++) {

Suggest sanity check array indexes before use, not after.
Comment 1 Michael Catanzaro 2017-06-14 15:58:47 UTC
Nice, I think these are both real bugs. What tool did you use to find these?
Comment 2 dcb 2017-06-14 16:59:07 UTC
(In reply to Michael Catanzaro from comment #1)
> Nice, I think these are both real bugs. 

Thanks.

> What tool did you use to find these?

A static analyser for C and C++ called cppcheck.

I find it very useful. It is available from sourceforge.

http://cppcheck.sourceforge.net/
Comment 3 Michael Catanzaro 2017-07-02 17:00:01 UTC
The following fixes have been pushed:
ab33eeb profile-migrator: Check limit before dereferencing
dfaf08c notebook: Check limit before dereferencing
Comment 4 Michael Catanzaro 2017-07-02 17:00:05 UTC
Created attachment 354798 [details] [review]
profile-migrator: Check limit before dereferencing
Comment 5 Michael Catanzaro 2017-07-02 17:00:10 UTC
Created attachment 354799 [details] [review]
notebook: Check limit before dereferencing