diff options
author | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2010-10-13 16:21:59 +0900 |
---|---|---|
committer | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2010-10-13 16:21:59 +0900 |
commit | 4b718714186313648a098b823f478ce8c006dc3b (patch) | |
tree | c4e4740630227e6cd90895599388ec8e91d1b121 /src/base | |
parent | 59eb9f8cfe7d1df379a2318316d1f04f80fba54a (diff) |
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.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/ftsystem.c | 17 |
1 files changed, 14 insertions, 3 deletions
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; |