Skip to content

Commit

Permalink
Don't read beyond buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Jul 15, 2015
1 parent 0d10ae6 commit f2a8d48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ size_t base64_decode(char* buf,
while (src < srcEnd && dst < dstEnd) {
int remaining = srcEnd - src;

while (unbase64(*src) < 0 && src < srcEnd)
while (src < srcEnd && unbase64(*src) < 0)
src++, remaining--;
if (remaining == 0 || *src == '=')
break;
a = unbase64(*src++);

while (unbase64(*src) < 0 && src < srcEnd)
while (src < srcEnd && unbase64(*src) < 0)
src++, remaining--;
if (remaining <= 1 || *src == '=')
break;
Expand All @@ -182,7 +182,7 @@ size_t base64_decode(char* buf,
if (dst == dstEnd)
break;

while (unbase64(*src) < 0 && src < srcEnd)
while (src < srcEnd && unbase64(*src) < 0)
src++, remaining--;
if (remaining <= 2 || *src == '=')
break;
Expand All @@ -192,7 +192,7 @@ size_t base64_decode(char* buf,
if (dst == dstEnd)
break;

while (unbase64(*src) < 0 && src < srcEnd)
while (src < srcEnd && unbase64(*src) < 0)
src++, remaining--;
if (remaining <= 3 || *src == '=')
break;
Expand Down

0 comments on commit f2a8d48

Please sign in to comment.