summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/ftp/ftpinpstr.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-16 11:19:29 +0100
committerPetr Mladek <pmladek@suse.cz>2011-08-16 15:01:06 +0200
commitc0887806c54985a22e7a6688fee113dd17ceaeaa (patch)
tree35ebf98a4590fa51cc81c0bb9c4f409d4116e104 /ucb/source/ucp/ftp/ftpinpstr.cxx
parent1e7daaf843293ecac51dc3a4c93bb85bf6823264 (diff)
Related: fdo#39376/fdo#34880 short fread isn't an error when its eof
Signed-off-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'ucb/source/ucp/ftp/ftpinpstr.cxx')
-rw-r--r--ucb/source/ucp/ftp/ftpinpstr.cxx18
1 files changed, 4 insertions, 14 deletions
diff --git a/ucb/source/ucp/ftp/ftpinpstr.cxx b/ucb/source/ucp/ftp/ftpinpstr.cxx
index c1f7558d45..87af4c393c 100644
--- a/ucb/source/ucp/ftp/ftpinpstr.cxx
+++ b/ucb/source/ucp/ftp/ftpinpstr.cxx
@@ -52,8 +52,6 @@ FTPInputStream::FTPInputStream(FILE* tmpfl)
: m_tmpfl(tmpfl ? tmpfl : tmpfile())
{
fseek(m_tmpfl,0,SEEK_END);
-// fpos_t pos;
-// fgetpos(m_tmpfl,&pos);
long pos = ftell(m_tmpfl);
rewind(m_tmpfl);
m_nLength = sal_Int64(pos);
@@ -107,20 +105,12 @@ sal_Int32 SAL_CALL FTPInputStream::readBytes(Sequence< sal_Int8 >& aData,
if(0 <= nBytesToRead && aData.getLength() < nBytesToRead)
aData.realloc(nBytesToRead);
-// fpos_t bpos,epos;
-
-// fgetpos(m_tmpfl,&bpos);
-// fread(aData.getArray(),nBytesToRead,1,m_tmpfl);
-// fgetpos(m_tmpfl,&epos);
- long bpos,epos;
-
- bpos = ftell(m_tmpfl);
- if (fread(aData.getArray(),nBytesToRead,1,m_tmpfl) != 1)
+ size_t nWanted = static_cast<size_t>(nBytesToRead);
+ size_t nRead = fread(aData.getArray(), 1, nWanted, m_tmpfl);
+ if (nRead != nWanted && ferror(m_tmpfl))
throw IOException();
- epos = ftell(m_tmpfl);
-
- return sal_Int32(epos-bpos);
+ return static_cast<sal_Int32>(nRead);
}