diff options
author | beck <> | 2014-04-16 20:36:35 +0000 |
---|---|---|
committer | beck <> | 2014-04-16 20:36:35 +0000 |
commit | 750d86a4fc04f53024575d65269281ea6c4e450c (patch) | |
tree | 4a8d2bd6f2dd786d658a75ea2db858806f2ec5f4 /src/lib/libcrypto/x509v3 | |
parent | be77aa550ef0450b00eb62880d4d98112ba86e50 (diff) | |
download | openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.tar.gz openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.tar.bz2 openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.zip |
Clean up dangerous strncpy use. This included a use where the resulting
string was potentially not nul terminated and a place where malloc return
was unchecked.
while we're at it remove dummytest.c
ok miod@
Diffstat (limited to 'src/lib/libcrypto/x509v3')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_alt.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_info.c | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c index 66ea96db51..8de5dd041b 100644 --- a/src/lib/libcrypto/x509v3/v3_alt.c +++ b/src/lib/libcrypto/x509v3/v3_alt.c | |||
@@ -579,10 +579,12 @@ static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) | |||
579 | return 0; | 579 | return 0; |
580 | objlen = p - value; | 580 | objlen = p - value; |
581 | objtmp = OPENSSL_malloc(objlen + 1); | 581 | objtmp = OPENSSL_malloc(objlen + 1); |
582 | strncpy(objtmp, value, objlen); | 582 | if (objtmp) { |
583 | objtmp[objlen] = 0; | 583 | strlcpy(objtmp, value, objlen + 1); |
584 | gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0); | 584 | gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0); |
585 | OPENSSL_free(objtmp); | 585 | OPENSSL_free(objtmp); |
586 | } else | ||
587 | gen->d.otherName->type_id = NULL; | ||
586 | if (!gen->d.otherName->type_id) | 588 | if (!gen->d.otherName->type_id) |
587 | return 0; | 589 | return 0; |
588 | return 1; | 590 | return 1; |
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c index e1b8699f92..44bc3e1105 100644 --- a/src/lib/libcrypto/x509v3/v3_info.c +++ b/src/lib/libcrypto/x509v3/v3_info.c | |||
@@ -165,8 +165,7 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *metho | |||
165 | X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE); | 165 | X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE); |
166 | goto err; | 166 | goto err; |
167 | } | 167 | } |
168 | strncpy(objtmp, cnf->name, objlen); | 168 | strlcpy(objtmp, cnf->name, objlen + 1); |
169 | objtmp[objlen] = 0; | ||
170 | acc->method = OBJ_txt2obj(objtmp, 0); | 169 | acc->method = OBJ_txt2obj(objtmp, 0); |
171 | if(!acc->method) { | 170 | if(!acc->method) { |
172 | X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT); | 171 | X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT); |