Navigation


Changeset 1316:2e868f71832f in freeDiameter for libfdproto


Ignore:
Timestamp:
Dec 10, 2016, 11:12:02 PM (7 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Tentative fix for invalid pointers reported by Thomas.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/dictionary.c

    r1281 r1316  
    262262
    263263/* Initialize the "data" part of an object */
    264 static int init_object_data(struct dict_object * dest, void * source, enum dict_object_type type)
     264static int init_object_data(struct dict_object * dest, void * source, enum dict_object_type type, int dupos)
    265265{
    266266        TRACE_ENTRY("%p %p %d", dest, source, type);
     
    287287                case DICT_ENUMVAL:
    288288                        DUP_string_len( dest->data.enumval.enum_name, &dest->datastr_len );
     289                        if (dupos) {
     290                                // we also need to duplicate the octetstring constant value since it is a pointer.
     291                                dest->data.enumval.enum_value.os.data = os0dup(
     292                                                ((struct dict_enumval_data *)source)->enum_value.os.data,
     293                                                ((struct dict_enumval_data *)source)->enum_value.os.len
     294                                        );
     295                        }
    289296                        break;
    290297
     
    16051612{
    16061613        int ret = 0;
     1614        int dupos = 0;
    16071615        struct dict_object * new = NULL;
    16081616        struct dict_object * vendor = NULL;
     
    16551663                CHECK_PARAMS_DO( ((struct dict_cmd_data *)data)->cmd_flag_mask & CMD_FLAG_REQUEST, goto error_param   );
    16561664        }
     1665
     1666        /* For ENUMVAL object, check if the parent type is an OctetString */
     1667        if (type == DICT_ENUMVAL) {
     1668                if (parent->data.type.type_base == AVP_TYPE_OCTETSTRING)
     1669                        dupos = 1;
     1670        }
    16571671       
    16581672        /* We have to check that the new values are not equal to the sentinels */
     
    16691683        /* Initialize the data of the new object */
    16701684        init_object(new, type);
    1671         init_object_data(new, data, type);
     1685        init_object_data(new, data, type, dupos);
    16721686        new->dico = dict;
    16731687        new->parent = parent;
Note: See TracChangeset for help on using the changeset viewer.