Changeset 107:4586e930769b in roaraudio


Ignore:
Timestamp:
07/13/08 02:50:30 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

fixed overflow bugs

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/meta.c

    r96 r107  
    3939   } 
    4040 
    41    if ( (c = malloc(strlen(val))) == NULL ) { 
     41   if ( (c = malloc(strlen(val)+1)) == NULL ) { 
    4242    s->meta[i].type = ROAR_META_TYPE_NONE; 
    4343    s->meta[i].key[0] = 0; 
     
    5858 
    5959int stream_meta_get   (int id, int type, char * name, char * val, size_t len) { 
    60  int i; 
     60 int i, vallen; 
    6161 struct roar_stream_server * s = g_streams[id]; 
    6262 
     
    7070     continue; 
    7171 
    72    if ( strlen(s->meta[i].value) > (len - 1) ) 
     72   if ( (vallen = strlen(s->meta[i].value)) > (len - 1) ) { 
     73    ROAR_DBG("stream_meta_get(*): val too small: need %i have %i", vallen, len); 
    7374    return -1; 
     75   } 
    7476 
    75    strcpy(val, s->meta[i].value); 
     77   strncpy(val, s->meta[i].value, vallen); 
     78   val[vallen] = 0; 
    7679 
    7780   return 0; 
  • roard/req.c

    r101 r107  
    203203 int vallen; 
    204204 int type; 
    205  char val[LIBROAR_BUFFER_MSGDATA-2]; 
     205 char val[LIBROAR_BUFFER_MSGDATA-1]; 
    206206 
    207207 if ( mes->datalen != 2 ) 
     
    224224 mes->data[1] = (unsigned char) vallen; 
    225225 
    226  strncpy(&(mes->data[2]), val, vallen); 
     226 val[vallen] = 0; 
     227 
     228 strncpy(&(mes->data[2]), val, vallen+1); 
    227229 
    228230 return 0; 
Note: See TracChangeset for help on using the changeset viewer.