summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/by_dir.c12
-rw-r--r--src/lib/libssl/src/crypto/x509/by_dir.c12
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)
208static int 208static int
209add_cert_dir(BY_DIR *ctx, const char *dir, int type) 209add_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)
208static int 208static int
209add_cert_dir(BY_DIR *ctx, const char *dir, int type) 209add_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);