From 7fae084ef37fc31c9f9ec9006d44bd5835678dfe Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Fri, 29 Jun 2001 10:20:52 +0000 Subject: Applied patch from Jim Hague. --- lib/rfsv16.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/rfsv16.cc') diff --git a/lib/rfsv16.cc b/lib/rfsv16.cc index f6518d9..15bb0aa 100644 --- a/lib/rfsv16.cc +++ b/lib/rfsv16.cc @@ -541,9 +541,10 @@ fread(const u_int32_t handle, unsigned char * const buf, const u_int32_t len, u_ { Enum res; unsigned char *p = buf; + long l; count = 0; - while (count < len) { + do { bufferStore a; // Read in blocks of 291 bytes; the maximum payload for @@ -564,11 +565,12 @@ fread(const u_int32_t handle, unsigned char * const buf, const u_int32_t len, u_ return E_PSI_GEN_NONE; return res; } - long l = a.getLen(); - memcpy(buf, a.getString(), l); - count += l; - p += l; - } + if ((l = a.getLen()) > 0) { + memcpy(p, a.getString(), l); + count += l; + p += l; + } + } while ((count < len) && (l > 0)); return res; } -- cgit v1.2.3