Bug 679700 - unsafe use of malloc
Summary: unsafe use of malloc
Keywords:
Status: CLOSED EOL
Alias: None
Product: Corosync Cluster Engine
Classification: Retired
Component: confdb
Version: 1.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
Assignee: Jan Friesse
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-23 09:21 UTC by Fabio Massimo Di Nitto
Modified: 2020-03-27 19:11 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-27 19:11:08 UTC


Attachments (Terms of Use)

Description Fabio Massimo Di Nitto 2011-02-23 09:21:55 UTC
static int object_key_get (
        hdb_handle_t object_handle,
        const void *key_name,
        size_t key_len,
        void **value,
        size_t *value_len)
{
        objdb_value_types_t t;
        int ret;
        char *key_name_str = (char*)key_name;
        char *key_name_terminated = NULL;

        if (key_name_str[key_len-1] != '\0') {
                key_name_terminated = malloc (key_len + 1);
                memcpy (key_name_terminated, key_name, key_len);
                key_name_terminated[key_len] = '\0';
                key_name_str = key_name_terminated;
        }

        ret = object_key_get_typed(object_handle,
                key_name_str,
                value, value_len, &t);
        if (key_name_terminated) {
                free (key_name_terminated);
        }
        return ret;
}

the malloc return is not checked and it could possibly leads to crash instead of returning graceful error....

tho you are doomed anyway if that malloc fails.. :)

Comment 1 Jan Friesse 2011-08-29 07:49:40 UTC
Another problem found by Fabio:

uid_determine and gid_determine in corosync (flatiron) use a malloc but you don't check for errors there


Note You need to log in before you can comment on or make changes to this bug.