From 69d6ecdeec2fa30f31701826fda6efe8c1a11732 Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 10 Jul 2014 21:58:08 +0000 Subject: Use size_t as realloc() size argument whenever possible. ok tedu@ --- src/lib/libcrypto/asn1/f_enum.c | 7 ++++--- src/lib/libcrypto/asn1/f_string.c | 7 ++++--- src/lib/libssl/src/crypto/asn1/f_enum.c | 7 ++++--- src/lib/libssl/src/crypto/asn1/f_string.c | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c index 952b908985..7cf0abb428 100644 --- a/src/lib/libcrypto/asn1/f_enum.c +++ b/src/lib/libcrypto/asn1/f_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_enum.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */ +/* $OpenBSD: f_enum.c,v 1.13 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -104,7 +104,8 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) int i, j,k, m,n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; - int num = 0, slen = 0, first = 1; + int first = 1; + size_t num = 0, slen = 0; bs->type = V_ASN1_ENUMERATED; @@ -154,7 +155,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) } i /= 2; if (num + i > slen) { - sp = realloc(s, (unsigned int)num + i); + sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c index edf43779a9..eec05f8110 100644 --- a/src/lib/libcrypto/asn1/f_string.c +++ b/src/lib/libcrypto/asn1/f_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_string.c,v 1.14 2014/06/12 15:49:27 deraadt Exp $ */ +/* $OpenBSD: f_string.c,v 1.15 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,7 +102,8 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) int i, j, k, m, n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; - int num = 0, slen = 0, first = 1; + int first = 1; + size_t num = 0, slen = 0; bufsize = BIO_gets(bp, buf, size); for (;;) { @@ -150,7 +151,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) } i /= 2; if (num + i > slen) { - sp = realloc(s, (unsigned int)num + i); + sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE); diff --git a/src/lib/libssl/src/crypto/asn1/f_enum.c b/src/lib/libssl/src/crypto/asn1/f_enum.c index 952b908985..7cf0abb428 100644 --- a/src/lib/libssl/src/crypto/asn1/f_enum.c +++ b/src/lib/libssl/src/crypto/asn1/f_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_enum.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */ +/* $OpenBSD: f_enum.c,v 1.13 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -104,7 +104,8 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) int i, j,k, m,n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; - int num = 0, slen = 0, first = 1; + int first = 1; + size_t num = 0, slen = 0; bs->type = V_ASN1_ENUMERATED; @@ -154,7 +155,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) } i /= 2; if (num + i > slen) { - sp = realloc(s, (unsigned int)num + i); + sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); diff --git a/src/lib/libssl/src/crypto/asn1/f_string.c b/src/lib/libssl/src/crypto/asn1/f_string.c index edf43779a9..eec05f8110 100644 --- a/src/lib/libssl/src/crypto/asn1/f_string.c +++ b/src/lib/libssl/src/crypto/asn1/f_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_string.c,v 1.14 2014/06/12 15:49:27 deraadt Exp $ */ +/* $OpenBSD: f_string.c,v 1.15 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,7 +102,8 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) int i, j, k, m, n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; - int num = 0, slen = 0, first = 1; + int first = 1; + size_t num = 0, slen = 0; bufsize = BIO_gets(bp, buf, size); for (;;) { @@ -150,7 +151,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) } i /= 2; if (num + i > slen) { - sp = realloc(s, (unsigned int)num + i); + sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE); -- cgit v1.2.3-55-g6feb