Uploaded image for project: 'MaxScale'
  1. MaxScale
  2. MXS-390

Lack of checks of dynamic memory allocation

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 2.1.0
    • Component/s: N/A
    • Labels:
      None
    • Environment:
      Any

      Description

      Reviewing use of malloc and calloc shows (on a cursory check - there could be mistakes here):

      • Function add_slash in log_manager.cc is used in such a way that memory allocation failures are not checked and memory can be leaked.
      • config.c does not check malloc at line 517 - but this is not very important as a failure is likely to crash the system during startup and is also very unlikely to happen
      • dbusers.c does not check malloc at line 611 - but only a single byte is being allocated and formed into a null string so failure here is very unlikely
      • In gateway.c line 658 malloc return is not checked
      • In gateway.c line 908 malloc return is not checked
      • In gateway.c line 1966 calloc return is not checked
      • load_utils.c line 782 does not check malloc of a single byte - very unlikely to fail
      • poll.c line 221 does not check malloc, but this is during startup and is likely to cause an immediate crash in the unlikely event of a failure. Likewise lines 234 and 237.
      • secrets.c line 414 does not check malloc return.
      • harness_common.c has various unchecked mallocs and callocs
      • dbwfilter.c line 293 has unchecked malloc, likewise line 973
      • dbwfilter.c line 534, 725, 1122, 1794 have unchecked calloc
      • dbwfilter.c is not strictly correct in lines 1299ff because it does not back out dynamic allocations (trivial)
      • dbwfilter.c line 1913 does not check malloc return, likewise 1969
      • dbwfilter.c line 2199 does not check malloc return (conditionally compiled code)
      • mqfilter.c line 491 does not check malloc return, likewise line 569, 581, 591, 599.
      • mqfilter.c line 1023, 1472 does not check calloc return
      • mqfilter.c line 1277 may need to check that variable prop is non-null; likewise 1486.
      • regexfilter.c line 440 does not check malloc return
      • mysql_client.c line 558 does not check malloc return; 430, 955, 1055 do not check calloc
      • mysql_common.c line 1806 does not check malloc return; likewise 1820
      • readwritesplit.c line 4369 does not check malloc return; likewise 4391; lines 1631, 1829 do not check calloc return
      • schemarouter.c line 603 does not check malloc return; likewise 3792, 3814; lines 1419, 1484 , 1560 do not check calloc return
      • shardrouter.c line 560 does not check malloc return
      • table_replication_consistency.c line 201 does not check malloc return; likewise 271, 333, 418
      • table_replication_listener.cpp line 134 and numerous others does not check malloc return
      • Likewise table_replication_parser.cpp and table_replication_metadata.cpp
      • skygw_utils.cc lines 1704,1705 do not check malloc return; 474, 708, 726, 806, 1319, 1711 do not check calloc.
      • log_manager.cc 2416 does not check calloc return; likewise 3181
      • classify.c line 37 does not check calloc return
      • query_classifier.cc line 1084 does not check calloc return
      • consumer.c lines 162 to 168 do not check calloc return, also 284-289, also 370
      • filter.c line 264 does not check calloc return
      • filter.c function filterAddParameter needs calloc and realloc usage refined
      • service.c line 756 does not check calloc return, but only a pointer is being allocated
      • topfilter.c line 305 does not check calloc return
      • mysql_mon.c line 839 does not check calloc return
      • httpd.c line 357 does not check calloc return
      • blr_file.c line 1232 does not check calloc return

      39 items

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              martin brampton martin brampton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: