Changeset 0e94c21 in subsurface


Ignore:
Timestamp:
Dec 26, 2017, 2:04:10 PM (4 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
da1d6e9
Parents:
efb2640
Message:

Cleanup: prevent potential out of bounds write

Since we cannot store tanks / gases past MAX_CYLINDERS (currently 20),
there is no point in analyzing those data.

Coverity CID 208339

Signed-off-by: Dirk Hohndel <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/libdivecomputer.c

    r9d2c52f6 r0e94c21  
    116116        bool no_volume = true;
    117117
    118         for (i = 0; i < ngases || i < ntanks; i++) {
     118        for (i = 0; i < MAX_CYLINDERS && (i < ngases || i < ntanks); i++) {
    119119                if (i < ngases) {
    120120                        dc_gasmix_t gasmix = { 0 };
     
    125125                                return rc;
    126126
    127                         if (i >= MAX_CYLINDERS)
    128                                 continue;
    129 
    130                          o2 = lrint(gasmix.oxygen * 1000);
     127                        o2 = lrint(gasmix.oxygen * 1000);
    131128                        he = lrint(gasmix.helium * 1000);
    132129
Note: See TracChangeset for help on using the changeset viewer.