summaryrefslogtreecommitdiff
path: root/main/openssl/crypto/objects/obj_dat.c
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-11-14 09:52:32 +0100
committerArne Schwabe <arne@rfc2549.org>2014-11-14 09:52:32 +0100
commitb28828796ad6d65ac463b41bba153f74e4531a6b (patch)
tree154b9f7436ae575e324f3374a5145e451bf649a8 /main/openssl/crypto/objects/obj_dat.c
parente7a6c1a987ebee1ddb2f908ca028d613a5c52490 (diff)
Update OpenSSL version
Diffstat (limited to 'main/openssl/crypto/objects/obj_dat.c')
-rw-r--r--main/openssl/crypto/objects/obj_dat.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/main/openssl/crypto/objects/obj_dat.c b/main/openssl/crypto/objects/obj_dat.c
index 8a342ba3..0b2f4424 100644
--- a/main/openssl/crypto/objects/obj_dat.c
+++ b/main/openssl/crypto/objects/obj_dat.c
@@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
-