diff options
| author | miod <> | 2014-09-23 20:01:11 +0000 |
|---|---|---|
| committer | miod <> | 2014-09-23 20:01:11 +0000 |
| commit | bd790d54c42ff79b98f9b8b96c3b33f3bcf6c757 (patch) | |
| tree | 9a8d411dd50766c666d754307851c74e9f133168 | |
| parent | ad04e6a1deb1fa849ae2c9a7ce2393dfee765f3f (diff) | |
| download | openbsd-bd790d54c42ff79b98f9b8b96c3b33f3bcf6c757.tar.gz openbsd-bd790d54c42ff79b98f9b8b96c3b33f3bcf6c757.tar.bz2 openbsd-bd790d54c42ff79b98f9b8b96c3b33f3bcf6c757.zip | |
Fix regression introduced in revision 1.15 by using strndup() instead of
strdup() to allocated directory list components.
ok jsing@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/x509/by_dir.c | 12 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/x509/by_dir.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c index a7dc2292bc..193adb12f9 100644 --- a/src/lib/libcrypto/x509/by_dir.c +++ b/src/lib/libcrypto/x509/by_dir.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: by_dir.c,v 1.32 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: by_dir.c,v 1.33 2014/09/23 20:01:11 miod Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -208,8 +208,9 @@ free_dir(X509_LOOKUP *lu) | |||
| 208 | static int | 208 | static int |
| 209 | add_cert_dir(BY_DIR *ctx, const char *dir, int type) | 209 | add_cert_dir(BY_DIR *ctx, const char *dir, int type) |
| 210 | { | 210 | { |
| 211 | int j, len; | 211 | int j; |
| 212 | const char *s, *ss, *p; | 212 | const char *s, *ss, *p; |
| 213 | ptrdiff_t len; | ||
| 213 | 214 | ||
| 214 | if (dir == NULL || !*dir) { | 215 | if (dir == NULL || !*dir) { |
| 215 | X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); | 216 | X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); |
| @@ -223,14 +224,13 @@ add_cert_dir(BY_DIR *ctx, const char *dir, int type) | |||
| 223 | BY_DIR_ENTRY *ent; | 224 | BY_DIR_ENTRY *ent; |
| 224 | ss = s; | 225 | ss = s; |
| 225 | s = p + 1; | 226 | s = p + 1; |
| 226 | len = (int)(p - ss); | 227 | len = p - ss; |
| 227 | if (len == 0) | 228 | if (len == 0) |
| 228 | continue; | 229 | continue; |
| 229 | for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { | 230 | for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { |
| 230 | ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); | 231 | ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); |
| 231 | if (strlen(ent->dir) == (size_t)len && | 232 | if (strlen(ent->dir) == (size_t)len && |
| 232 | strncmp(ent->dir, ss, | 233 | strncmp(ent->dir, ss, (size_t)len) == 0) |
| 233 | (unsigned int)len) == 0) | ||
| 234 | break; | 234 | break; |
| 235 | } | 235 | } |
| 236 | if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) | 236 | if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) |
| @@ -249,7 +249,7 @@ add_cert_dir(BY_DIR *ctx, const char *dir, int type) | |||
| 249 | } | 249 | } |
| 250 | ent->dir_type = type; | 250 | ent->dir_type = type; |
| 251 | ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); | 251 | ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); |
| 252 | ent->dir = strdup(ss); | 252 | ent->dir = strndup(ss, (size_t)len); |
| 253 | if (!ent->dir || !ent->hashes) { | 253 | if (!ent->dir || !ent->hashes) { |
| 254 | X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); | 254 | X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); |
| 255 | by_dir_entry_free(ent); | 255 | by_dir_entry_free(ent); |
diff --git a/src/lib/libssl/src/crypto/x509/by_dir.c b/src/lib/libssl/src/crypto/x509/by_dir.c index a7dc2292bc..193adb12f9 100644 --- a/src/lib/libssl/src/crypto/x509/by_dir.c +++ b/src/lib/libssl/src/crypto/x509/by_dir.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: by_dir.c,v 1.32 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: by_dir.c,v 1.33 2014/09/23 20:01:11 miod Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -208,8 +208,9 @@ free_dir(X509_LOOKUP *lu) | |||
| 208 | static int | 208 | static int |
| 209 | add_cert_dir(BY_DIR *ctx, const char *dir, int type) | 209 | add_cert_dir(BY_DIR *ctx, const char *dir, int type) |
| 210 | { | 210 | { |
| 211 | int j, len; | 211 | int j; |
| 212 | const char *s, *ss, *p; | 212 | const char *s, *ss, *p; |
| 213 | ptrdiff_t len; | ||
| 213 | 214 | ||
| 214 | if (dir == NULL || !*dir) { | 215 | if (dir == NULL || !*dir) { |
| 215 | X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); | 216 | X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); |
| @@ -223,14 +224,13 @@ add_cert_dir(BY_DIR *ctx, const char *dir, int type) | |||
| 223 | BY_DIR_ENTRY *ent; | 224 | BY_DIR_ENTRY *ent; |
| 224 | ss = s; | 225 | ss = s; |
| 225 | s = p + 1; | 226 | s = p + 1; |
| 226 | len = (int)(p - ss); | 227 | len = p - ss; |
| 227 | if (len == 0) | 228 | if (len == 0) |
| 228 | continue; | 229 | continue; |
| 229 | for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { | 230 | for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { |
| 230 | ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); | 231 | ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); |
| 231 | if (strlen(ent->dir) == (size_t)len && | 232 | if (strlen(ent->dir) == (size_t)len && |
| 232 | strncmp(ent->dir, ss, | 233 | strncmp(ent->dir, ss, (size_t)len) == 0) |
| 233 | (unsigned int)len) == 0) | ||
| 234 | break; | 234 | break; |
| 235 | } | 235 | } |
| 236 | if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) | 236 | if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) |
| @@ -249,7 +249,7 @@ add_cert_dir(BY_DIR *ctx, const char *dir, int type) | |||
| 249 | } | 249 | } |
| 250 | ent->dir_type = type; | 250 | ent->dir_type = type; |
| 251 | ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); | 251 | ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); |
| 252 | ent->dir = strdup(ss); | 252 | ent->dir = strndup(ss, (size_t)len); |
| 253 | if (!ent->dir || !ent->hashes) { | 253 | if (!ent->dir || !ent->hashes) { |
| 254 | X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); | 254 | X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); |
| 255 | by_dir_entry_free(ent); | 255 | by_dir_entry_free(ent); |
