projects
/
oweals
/
openssl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6378809
)
Make sure max in fmtstr() doesn't overflow into negativity
author
Richard Levitte
<levitte@openssl.org>
Mon, 30 May 2016 03:41:57 +0000
(
05:41
+0200)
committer
Richard Levitte
<levitte@openssl.org>
Mon, 30 May 2016 03:41:57 +0000
(
05:41
+0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/bio/b_print.c
patch
|
blob
|
history
diff --git
a/crypto/bio/b_print.c
b/crypto/bio/b_print.c
index 545c46981089c13774b8da088149316c909484ee..1b70bac71b1d6350dfe3d766026ac6e21a3b407c 100644
(file)
--- a/
crypto/bio/b_print.c
+++ b/
crypto/bio/b_print.c
@@
-390,8
+390,16
@@
fmtstr(char **sbuffer,
padlen = min - strln;
if (min < 0 || padlen < 0)
padlen = 0;
- if (max >= 0)
- max += padlen; /* The maximum output including padding */
+ if (max >= 0) {
+ /*
+ * Calculate the maximum output including padding.
+ * Make sure max doesn't overflow into negativity
+ */
+ if (max < INT_MAX - padlen)
+ max += padlen;
+ else
+ max = INT_MAX;
+ }
if (flags & DP_F_MINUS)
padlen = -padlen;