diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | builds/amiga/src/base/ftsystem.c | 8 | ||||
-rw-r--r-- | builds/vms/ftsystem.c | 7 | ||||
-rw-r--r-- | src/base/ftsystem.c | 17 |
4 files changed, 44 insertions, 3 deletions
@@ -1,3 +1,18 @@ +2010-10-13 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> + + Prevent to open a FT_Stream for zero-sized file on non-Unix. + + builds/unix/ftsystem.c prevents to open an useless stream from + zero-sized file and returns FT_Err_Cannot_Open_Stream, but the + stream drivers for ANSI C, Amiga and VMS return useless streams. + For cross-platform consistency, all stream drivers should act + same. + + * src/base/ftsystem.c (FT_Stream_Open): If the size of the opened + file is zero, FT_Err_Cannot_Open_Stream is returned. + * builds/amiga/src/base/ftsystem.c (FT_Stream_Open): Ditto. + * src/vms/ftsystem.c (FT_Stream_Open): Ditto. + 2010-10-12 Werner Lemberg <wl@gnu.org> Fix Savannah bug #31310. diff --git a/builds/amiga/src/base/ftsystem.c b/builds/amiga/src/base/ftsystem.c index 016f1e29..a2619886 100644 --- a/builds/amiga/src/base/ftsystem.c +++ b/builds/amiga/src/base/ftsystem.c @@ -442,6 +442,14 @@ Free_VecPooled( APTR poolHeader, stream->read = ft_amiga_stream_io; stream->close = ft_amiga_stream_close; + if ( !stream->size ) + { + ft_amiga_stream_close( stream ); + FT_ERROR(( "FT_Stream_Open:" )); + FT_ERROR(( " opened `%s' but zero-sized\n", filepathname )); + return FT_Err_Cannot_Open_Stream;; + } + FT_TRACE1(( "FT_Stream_Open:" )); FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n", filepathname, stream->size )); diff --git a/builds/vms/ftsystem.c b/builds/vms/ftsystem.c index 76bfae9f..0c98f030 100644 --- a/builds/vms/ftsystem.c +++ b/builds/vms/ftsystem.c @@ -231,6 +231,13 @@ } stream->size = stat_buf.st_size; + if ( !stream->size ) + { + FT_ERROR(( "FT_Stream_Open:" )); + FT_ERROR(( " opened `%s' but zero-sized\n", filepathname )); + goto Fail_Map; + } + stream->pos = 0; stream->base = (unsigned char *)mmap( NULL, stream->size, diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c index ba86005c..66c5d76a 100644 --- a/src/base/ftsystem.c +++ b/src/base/ftsystem.c @@ -229,6 +229,13 @@ if ( !stream ) return FT_Err_Invalid_Stream_Handle; + stream->descriptor.pointer = NULL; + stream->pathname.pointer = (char*)filepathname; + stream->base = 0; + stream->pos = 0; + stream->read = NULL; + stream->close = NULL; + file = ft_fopen( filepathname, "rb" ); if ( !file ) { @@ -240,12 +247,16 @@ ft_fseek( file, 0, SEEK_END ); stream->size = ft_ftell( file ); + if ( !stream->size ) + { + FT_ERROR(( "FT_Stream_Open:" )); + FT_ERROR(( " opened `%s' but zero-sized\n", filepathname )); + ft_fclose( file ); + return FT_Err_Cannot_Open_Stream; + } ft_fseek( file, 0, SEEK_SET ); stream->descriptor.pointer = file; - stream->pathname.pointer = (char*)filepathname; - stream->pos = 0; - stream->read = ft_ansi_stream_io; stream->close = ft_ansi_stream_close; |