diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-03-07 18:42:47 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-03-08 13:35:27 +0100 |
commit | 8fcc60bee755b812489ef652ab2fa779babddeac (patch) | |
tree | e64275490754650dfddea2e46a00f557799e303c /vcl | |
parent | 5c1c0a4eef933816685364feef93dfb090ff391d (diff) |
protect against incomplete writes
What good is an abstraction if one still has to fiddle with annoying
implementation details?
Change-Id: I80816bdad8c0560263306584ad001a41fc054cd2
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/embeddedfontshelper.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index 5df758da0f04..691e434f0cc7 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -69,15 +69,22 @@ bool EmbeddedFontsHelper::addEmbeddedFont( uno::Reference< io::XInputStream > st for(;;) { uno::Sequence< sal_Int8 > buffer; - int read = stream->readBytes( buffer, 1024 ); - for( int pos = 0; + sal_uInt64 read = stream->readBytes( buffer, 1024 ); + for( sal_uInt64 pos = 0; pos < read && keyPos < key.size(); ++pos ) buffer[ pos ] ^= key[ keyPos++ ]; - sal_uInt64 dummy; if( read > 0 ) - file.write( buffer.getConstArray(), read, dummy ); - if( read < 1024 ) + { + sal_uInt64 writtenTotal = 0; + while( writtenTotal < read ) + { + sal_uInt64 written; + file.write( buffer.getConstArray(), read, written ); + writtenTotal += written; + } + } + if( read <= 0 ) break; } if( file.close() != osl::File::E_None ) |