]> git.sesse.net Git - vlc/commitdiff
* src/input/input_ext-plugins.c, src/input/input_ext-intf.c: boundary checks
authorSam Hocevar <sam@videolan.org>
Tue, 21 May 2002 00:23:37 +0000 (00:23 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 21 May 2002 00:23:37 +0000 (00:23 +0000)
    on seek.

src/input/input_ext-intf.c
src/input/input_ext-plugins.c

index d4f369d10497d2781d0c53853246ef0bdfad9fd6..43ad926f248ed1c7b97d8bc2178242ca5e8431cb 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-intf.c: services to the interface
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ext-intf.c,v 1.35 2002/03/05 17:46:33 stef Exp $
+ * $Id: input_ext-intf.c,v 1.36 2002/05/21 00:23:37 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -130,10 +130,18 @@ void input_Seek( input_thread_t * p_input, off_t i_position )
     char        psz_time2[OFFSETTOTIME_MAX_SIZE];
 
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.p_selected_area->i_seek = i_position;
+    if( i_position < 0 )
+    {
+        i_position = 0;
+    }
+    else if( i_position >= p_input->stream.p_selected_area->i_size )
+    {
+        i_position = p_input->stream.p_selected_area->i_size;
+    }
 
-    intf_WarnMsg( 3, "input: seeking position %lld/%lld (%s/%s)", i_position,
-                  p_input->stream.p_selected_area->i_size,
+    p_input->stream.p_selected_area->i_seek = i_position;
+    intf_WarnMsg( 3, "input: seeking position %lld/%lld (%s/%s)",
+                  i_position, p_input->stream.p_selected_area->i_size,
                   input_OffsetToTime( p_input, psz_time1, i_position ),
                   input_OffsetToTime( p_input, psz_time2,
                               p_input->stream.p_selected_area->i_size ) );
index 5a478988513a0f58533514932a18272f9ae13f75..3d7a9b34f007b93a1cf1010525464258db9d32f1 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-plugins.c: useful functions for access and demux plug-ins
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: input_ext-plugins.c,v 1.9 2002/05/18 17:47:47 sam Exp $
+ * $Id: input_ext-plugins.c,v 1.10 2002/05/21 00:23:37 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -790,13 +790,25 @@ ssize_t input_FDNetworkRead( input_thread_t * p_input, byte_t * p_buffer,
  *****************************************************************************/
 void input_FDSeek( input_thread_t * p_input, off_t i_pos )
 {
+#define S p_input->stream
     input_socket_t * p_access_data = (input_socket_t *)p_input->p_access_data;
 
     lseek( p_access_data->i_handle, i_pos, SEEK_SET );
 
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.p_selected_area->i_tell = i_pos;
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
+    vlc_mutex_lock( &S.stream_lock );
+    S.p_selected_area->i_tell = i_pos;
+    if( S.p_selected_area->i_tell > S.p_selected_area->i_size )
+    {
+        intf_ErrMsg( "input error: seeking too far" );
+        S.p_selected_area->i_tell = S.p_selected_area->i_size;
+    }
+    else if( S.p_selected_area->i_tell < 0 )
+    {
+        intf_ErrMsg( "input error: seeking too early" );
+        S.p_selected_area->i_tell = 0;
+    }
+    vlc_mutex_unlock( &S.stream_lock );
+#undef S
 }