Changeset 715:d88f46a43a03 in roaraudio


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

got a bug reported by stephan48 fixed, do not process meta data longer than our buffers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarvorbis.c

    r669 r715  
    6666 int    codec    = ROAR_CODEC_DEFAULT; 
    6767 char **ptr = ov_comment(vf, -1)->user_comments; 
    68  char key[80], value[80] = {0}; 
     68 char key[ROAR_META_MAX_NAMELEN], value[ROAR_META_MAX_NAMELEN] = {0}; 
    6969 int j, h = 0; 
    7070 struct roar_meta   meta; 
    7171 int need_new_stream = 0; 
     72 int meta_ok; 
    7273 
    7374 fprintf(stderr, "\n"); 
     
    106107  meta.type = ROAR_META_TYPE_FILENAME; 
    107108 
    108  strncpy(value, file, 79); 
     109 
     110 strncpy(value, file, ROAR_META_MAX_NAMELEN-1); 
     111 value[ROAR_META_MAX_NAMELEN-1] = 0; 
    109112 roar_stream_meta_set(con, s, ROAR_META_MODE_SET, &meta); 
    110113 
    111114 while(*ptr){ 
    112    for (j = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
     115  meta_ok = 1; 
     116 
     117   for (j = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) { 
     118    if ( j == ROAR_META_MAX_NAMELEN ) { 
     119     ROAR_ERR("update_stream(*): invalid meta data: meta data key too long"); 
     120     meta_ok = 0; 
     121     j = 0; 
     122     break; 
     123    } 
    113124    key[j] = (*ptr)[j]; 
    114     key[j] = 0; 
    115  
    116    for (j++, h = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
    117     value[h++] = (*ptr)[j]; 
     125   } 
     126   key[j] = 0; 
     127 
     128   if ( meta_ok ) { 
     129    for (j++, h = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) { 
     130     if ( h == ROAR_META_MAX_NAMELEN ) { 
     131      ROAR_ERR("update_stream(*): invalid meta data: meta data value for key '%s' too long", key); 
     132      meta_ok = 0; 
     133      h = 0; 
     134      break; 
     135     } 
     136     value[h++] = (*ptr)[j]; 
     137    } 
    118138    value[h]   = 0; 
    119  
    120    meta.type = roar_meta_inttype(key); 
    121    if ( meta.type != -1 ) 
    122     roar_stream_meta_set(con, s, ROAR_META_MODE_SET, &meta); 
    123  
    124    fprintf(stderr, "Meta %-16s: %s\n", key, value); 
    125    ++ptr; 
     139   } 
     140 
     141   if ( meta_ok ) { 
     142    fprintf(stderr, "Meta %-16s: %s\n", key, value); 
     143 
     144    meta.type = roar_meta_inttype(key); 
     145    if ( meta.type != -1 ) 
     146     roar_stream_meta_set(con, s, ROAR_META_MODE_SET, &meta); 
     147   } 
     148 
     149   ptr++; 
    126150 } 
    127151 
     
    203227  if ( last_section != current_section ) 
    204228   if ( update_stream(&con, &s, &out, &vf, file, &info) == -1 ) 
    205     return -1; 
     229    return 1; 
    206230 
    207231  last_section = current_section; 
Note: See TracChangeset for help on using the changeset viewer.