diff options
author | deraadt <> | 2003-04-04 18:34:45 +0000 |
---|---|---|
committer | deraadt <> | 2003-04-04 18:34:45 +0000 |
commit | 4692eff0d0561807c5e064b06ced6191dc6fbbda (patch) | |
tree | af22995da5f7a8ad0d545f15c2e13cee299fa2b4 | |
parent | 51cfbad8720d74250fd6d37c8986e1b47d588f8d (diff) | |
download | openbsd-4692eff0d0561807c5e064b06ced6191dc6fbbda.tar.gz openbsd-4692eff0d0561807c5e064b06ced6191dc6fbbda.tar.bz2 openbsd-4692eff0d0561807c5e064b06ced6191dc6fbbda.zip |
incorrect bounds limit; spotted by ho
-rw-r--r-- | src/lib/libssl/src/apps/x509.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c index 3ff4b62481..bc280d2c39 100644 --- a/src/lib/libssl/src/apps/x509.c +++ b/src/lib/libssl/src/apps/x509.c | |||
@@ -1026,24 +1026,26 @@ static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create) | |||
1026 | ASN1_INTEGER *bs = NULL, *bs2 = NULL; | 1026 | ASN1_INTEGER *bs = NULL, *bs2 = NULL; |
1027 | BIO *io = NULL; | 1027 | BIO *io = NULL; |
1028 | BIGNUM *serial = NULL; | 1028 | BIGNUM *serial = NULL; |
1029 | size_t len; | ||
1029 | 1030 | ||
1030 | buf=OPENSSL_malloc( ((serialfile == NULL) | 1031 | len = ((serialfile == NULL) |
1031 | ?(strlen(CAfile)+strlen(POSTFIX)+1) | 1032 | ?(strlen(CAfile)+strlen(POSTFIX)+1) |
1032 | :(strlen(serialfile)))+1); | 1033 | :(strlen(serialfile)))+1); |
1034 | buf=OPENSSL_malloc(len); | ||
1033 | if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; } | 1035 | if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; } |
1034 | if (serialfile == NULL) | 1036 | if (serialfile == NULL) |
1035 | { | 1037 | { |
1036 | strlcpy(buf,CAfile,sizeof buf); | 1038 | strlcpy(buf,CAfile,len); |
1037 | for (p=buf; *p; p++) | 1039 | for (p=buf; *p; p++) |
1038 | if (*p == '.') | 1040 | if (*p == '.') |
1039 | { | 1041 | { |
1040 | *p='\0'; | 1042 | *p='\0'; |
1041 | break; | 1043 | break; |
1042 | } | 1044 | } |
1043 | strcat(buf,POSTFIX); | 1045 | strlcat(buf,POSTFIX,len); |
1044 | } | 1046 | } |
1045 | else | 1047 | else |
1046 | strlcpy(buf,serialfile,sizeof buf); | 1048 | strlcpy(buf,serialfile,len); |
1047 | serial=BN_new(); | 1049 | serial=BN_new(); |
1048 | bs=ASN1_INTEGER_new(); | 1050 | bs=ASN1_INTEGER_new(); |
1049 | if ((serial == NULL) || (bs == NULL)) | 1051 | if ((serial == NULL) || (bs == NULL)) |