Skip to content

Commit

Permalink
Avoid creating an illegal pointer.
Browse files Browse the repository at this point in the history
Found by tis-interpreter

Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1230
  • Loading branch information
kroeckx committed Jun 21, 2016
1 parent 5b8fa43 commit 5388b8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crypto/asn1/a_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ static size_t i2c_ibuf(const unsigned char *b, size_t blen, int neg,
memcpy(p, b, blen);
else {
/* Begin at the end of the encoding */
n = b + blen - 1;
p += blen - 1;
n = b + blen;
p += blen;
i = blen;
/* Copy zeros to destination as long as source is zero */
while (!*n && i > 1) {
*(p--) = 0;
while (!n[-1] && i > 1) {
*(--p) = 0;
n--;
i--;
}
/* Complement and increment next octet */
*(p--) = ((*(n--)) ^ 0xff) + 1;
*(--p) = ((*(--n)) ^ 0xff) + 1;
i--;
/* Complement any octets left */
for (; i > 0; i--)
*(p--) = *(n--) ^ 0xff;
*(--p) = *(--n) ^ 0xff;
}

*pp += ret;
Expand Down

0 comments on commit 5388b8d

Please sign in to comment.