[xiph-cvs] cvs commit: vorbis/lib vorbisfile.c

Monty xiphmont at xiph.org
Wed Sep 12 19:17:52 PDT 2001



xiphmont    01/09/12 19:17:51

  Modified:    lib      vorbisfile.c
  Log:
  Fixed:
  
  1) now check return value from header fetch in the new link of a chained stream
  2) harden vorbisfile against garbage bytes between header pages

Revision  Changes    Path
1.49      +12 -19    vorbis/lib/vorbisfile.c

Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisfile.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- vorbisfile.c	2001/06/02 11:38:14	1.48
+++ vorbisfile.c	2001/09/13 02:17:51	1.49
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.48 2001/06/02 11:38:14 msmith Exp $
+ last mod: $Id: vorbisfile.c,v 1.49 2001/09/13 02:17:51 xiphmont Exp $
 
  ********************************************************************/
 
@@ -260,7 +260,7 @@
       i++;
     }
     if(i<3)
-      if(_get_next_page(vf,og_ptr,1)<0){
+      if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){
         ret=OV_EBADHEADER;
         goto bail_header;
       }
@@ -271,6 +271,8 @@
   vorbis_info_clear(vi);
   vorbis_comment_clear(vc);
   ogg_stream_clear(&vf->os);
+  vf->ready_state=OPENED;
+
   return ret;
 }
 
@@ -477,11 +479,10 @@
       }
     }
 
-    if(vf->ready_state>=STREAMSET){
+    if(vf->ready_state>=OPENED){
       if(!readp)return(0);
       if(_get_next_page(vf,&og,-1)<0)return(OV_EOF); /* eof. 
                                                         leave unitialized */
-      
       /* bitrate tracking; add the header's bytes here, the body bytes
          are done by packet above */
       vf->bittrack+=og.header_len*8;
@@ -538,7 +539,8 @@
           /* we're streaming */
           /* fetch the three header packets, build the info struct */
           
-	  _fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og);
+	  int ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og);
+	  if(ret)return(ret);
           vf->current_link++;
           link=0;
         }
@@ -1372,13 +1374,6 @@
   int host_endian = host_is_big_endian();
 
   if(vf->ready_state<OPENED)return(OV_EINVAL);
-  if(vf->ready_state==OPENED)return(OV_EOF); /* stream is always
-						initialized after
-						other calls (after
-						open)... unless there
-						was no page at the end
-						to initialize state
-						with. */
 
   while(1){
     if(vf->ready_state>=STREAMSET){
@@ -1483,14 +1478,12 @@
     }
 
     /* suck in another packet */
-    switch(_process_packet(vf,1)){
-    case 0:case OV_EOF:
-      return(0);
-    case OV_HOLE:
-      return(OV_HOLE);
-    case OV_EBADLINK:
-      return(OV_EBADLINK);
+    {
+      int ret=_process_packet(vf,1);
+      if(ret==OV_EOF)return(0);
+      if(ret<=0)return(ret);
     }
+
   }
 }
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list