From 0f599eb9b1a2fd87d9bf235267e52ee43304dbd0 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 30 May 2015 16:56:56 +0000 Subject: Fix buffer overrun, garbage first row output git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2530 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/pbm/pbmtogo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'converter/pbm') diff --git a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c index b4f3f372..23b2ee9a 100644 --- a/converter/pbm/pbmtogo.c +++ b/converter/pbm/pbmtogo.c @@ -164,7 +164,7 @@ main(int argc, padright = rucols - cols; for (i = 0; i < GRAPHON_WIDTH_BYTES; ++i ) - buffer[i] = 0; + buffer[i] = oldscanline[i] = 0; putinit(); /* Start donwloading screen raster */ @@ -215,7 +215,7 @@ main(int argc, { olditem = buffer[nbyte++]; ucount++; - } while ((olditem != buffer[nbyte]) + } while (nbyte < bytesperrow && (olditem != buffer[nbyte]) && (ucount < MIN(bytesperrow, MAX_REPEAT))); if ((ucount != MAX_REPEAT) && (nbyte != bytesperrow)) { @@ -246,7 +246,7 @@ main(int argc, { olditem = buffer[nbyte++]; ecount++; - } while ((olditem == buffer[nbyte]) + } while (nbyte < bytesperrow && (olditem == buffer[nbyte]) && (ecount < MIN(bytesperrow, MAX_REPEAT))); if (ecount > 1) { -- cgit 1.4.1