Changeset f351efa7d22645625d20204f86a44b194fde8352

Show
Ignore:
Timestamp:
03/19/08 16:31:07 (2 months ago)
Author:
Pavlov Konstantin <thresh@altlinux.ru>
git-committer:
Pavlov Konstantin <thresh@altlinux.ru> 1205940667 +0300
git-parent:

[16c69ade84edabaf8c861f1e4f478ae815f94970]

git-author:
Pavlov Konstantin <thresh@altlinux.ru> 1205940667 +0300
Message:

Fix Array Indexing Vulnerability in sdpplin_parse(). (CVE-2008-0073). (closes #1531).
Thanks to Alin Rad Pop, Secunia Research.
Ported from libxine.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access/rtsp/real_sdpplin.c

    r9630c00 rf351efa  
    139139 
    140140    if(filter(*data,"a=control:streamid=",&buf, BUFLEN)) { 
    141       desc->stream_id=atoi(buf); 
    142       handled=1; 
    143       *data=nl(*data); 
     141        /* This way negative values are mapped to unfeasibly high 
     142         * values, and will be discarded afterward 
     143         */ 
     144        unsigned long tmp = strtoul(buf, NULL, 10); 
     145        if ( tmp > UINT16_MAX ) 
     146            lprintf("stream id out of bound: %lu\n", tmp); 
     147        else 
     148            desc->stream_id=tmp; 
     149        handled=1; 
     150        *data=nl(*data); 
    144151    } 
    145152    if(filter(*data,"a=MaxBitRate:integer;",&buf, BUFLEN)) { 
     
    255262        stream=sdpplin_parse_stream(&data); 
    256263        lprintf("got data for stream id %u\n", stream->stream_id); 
    257         desc->stream[stream->stream_id]=stream; 
     264        if ( stream->stream_id >= desc->stream_count ) 
     265            lprintf("stream id %u is greater than stream count %u\n", stream->stream_id, desc->stream_count); 
     266        else 
     267            desc->stream[stream->stream_id]=stream; 
    258268        continue; 
    259269    } 
     
    291301    } 
    292302    if(filter(data,"a=StreamCount:integer;",&buf, BUFLEN)) { 
    293       desc->stream_count=atoi(buf); 
    294       desc->stream = malloc(sizeof(sdpplin_stream_t*)*desc->stream_count); 
    295       handled=1; 
    296       data=nl(data); 
     303        /* This way negative values are mapped to unfeasibly high 
     304         * values, and will be discarded afterward 
     305         */ 
     306        unsigned long tmp = strtoul(buf, NULL, 10); 
     307        if ( tmp > UINT16_MAX ) 
     308            lprintf("stream count out of bound: %lu\n", tmp); 
     309        else 
     310            desc->stream_count = tmp; 
     311        desc->stream = malloc(sizeof(sdpplin_stream_t*)*desc->stream_count); 
     312        handled=1; 
     313        data=nl(data); 
    297314    } 
    298315    if(filter(data,"a=Flags:integer;",&buf, BUFLEN)) { 
  • modules/access/rtsp/real_sdpplin.h

    r2cb472d rf351efa  
    3232  char *bandwidth; 
    3333 
    34   int stream_id; 
     34  uint16_t stream_id; 
    3535  char *range; 
    3636  char *length; 
     
    7676  int flags; 
    7777  int is_real_data_type; 
    78   int stream_count; 
     78  uint16_t stream_count; 
    7979  char *title; 
    8080  char *author;