Skip to content
Browse files

match_backward(): don't overrun buffer when user supplies block size …

…more, than 4096 bytes

User can (And I did) pass large block sizes for initial passes,
but the code is not ready for it:

    match_backward() {
        ...
        if (numtoread > blocksize) numtoread = blocksize;
        Token buf1[4096], buf2[4096];
        const Token *read1 = b->read1(buf1, p1, numtoread),
        ...

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
1 parent 744c29d commit f61f24a20454dc83b3da847a7bd89b532cf2377a @trofi trofi committed Oct 31, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 src/libbdelta.cpp
View
1 src/libbdelta.cpp
@@ -113,6 +113,7 @@ unsigned match_backward(BDelta_Instance *b, unsigned p1, unsigned p2, unsigned b
do {
numtoread = std::min(p1, p2);
if (numtoread > blocksize) numtoread = blocksize;
+ if (numtoread > 4096) numtoread = 4096;
p1 -= numtoread; p2 -= numtoread;
Token buf1[4096], buf2[4096];
const Token *read1 = b->read1(buf1, p1, numtoread),

0 comments on commit f61f24a

Please sign in to comment.
Something went wrong with that request. Please try again.