projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Various fixes...
[oweals/openssl.git]
/
crypto
/
asn1
/
a_bytes.c
diff --git
a/crypto/asn1/a_bytes.c
b/crypto/asn1/a_bytes.c
index fdfe9ea8efda48f25d20e54714256d6e933926c2..3a0c0c783551bca509e3efa230625a65e63b7e2c 100644
(file)
--- a/
crypto/asn1/a_bytes.c
+++ b/
crypto/asn1/a_bytes.c
@@
-58,11
+58,7
@@
#include <stdio.h>
#include "cryptlib.h"
#include <stdio.h>
#include "cryptlib.h"
-#include "asn1_mac.h"
-
-/* ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES,ASN1_R_WRONG_TYPE);
- * ASN1err(ASN1_F_ASN1_COLLATE_PRIMATIVE,ASN1_R_WRONG_TAG);
- */
+#include <openssl/asn1_mac.h>
static unsigned long tag2bit[32]={
0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
static unsigned long tag2bit[32]={
0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
@@
-75,12
+71,7
@@
B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
};
B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
};
-#ifndef NOPROTO
-static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c);
-#else
-static int asn1_collate_primative();
-#endif
-
+static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
/* type is a 'bitmap' of acceptable string types.
*/
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
/* type is a 'bitmap' of acceptable string types.
*/
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
@@
-120,7
+111,7
@@
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
if (len != 0)
{
if (len != 0)
{
- s=(unsigned char *)
M
alloc((int)len+1);
+ s=(unsigned char *)
OPENSSL_m
alloc((int)len+1);
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
@@
-133,7
+124,7
@@
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
else
s=NULL;
else
s=NULL;
- if (ret->data != NULL)
Free((char *)
ret->data);
+ if (ret->data != NULL)
OPENSSL_free(
ret->data);
ret->length=(int)len;
ret->data=s;
ret->type=tag;
ret->length=(int)len;
ret->data=s;
ret->type=tag;
@@
-214,7
+205,7
@@
ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
c.tag=Ptag;
c.xclass=Pclass;
c.max=(length == 0)?0:(p+length);
c.tag=Ptag;
c.xclass=Pclass;
c.max=(length == 0)?0:(p+length);
- if (!asn1_collate_prim
a
tive(ret,&c))
+ if (!asn1_collate_prim
i
tive(ret,&c))
goto err;
else
{
goto err;
else
{
@@
-227,8
+218,8
@@
ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
{
if ((ret->length < len) || (ret->data == NULL))
{
{
if ((ret->length < len) || (ret->data == NULL))
{
- if (ret->data != NULL)
Free((char *)
ret->data);
- s=(unsigned char *)
Malloc((int)len
);
+ if (ret->data != NULL)
OPENSSL_free(
ret->data);
+ s=(unsigned char *)
OPENSSL_malloc((int)len + 1
);
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
@@
-238,12
+229,13
@@
ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
else
s=ret->data;
memcpy(s,p,(int)len);
else
s=ret->data;
memcpy(s,p,(int)len);
+ s[len] = '\0';
p+=len;
}
else
{
s=NULL;
p+=len;
}
else
{
s=NULL;
- if (ret->data != NULL)
Free((char *)
ret->data);
+ if (ret->data != NULL)
OPENSSL_free(
ret->data);
}
ret->length=(int)len;
}
ret->length=(int)len;
@@
-262,11
+254,11
@@
err:
}
}
-/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collap
es
- * them into the one struture that is then returned */
+/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collap
se
+ * them into the one stru
c
ture that is then returned */
/* There have been a few bug fixes for this function from
* Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
/* There have been a few bug fixes for this function from
* Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
-static int asn1_collate_prim
a
tive(ASN1_STRING *a, ASN1_CTX *c)
+static int asn1_collate_prim
i
tive(ASN1_STRING *a, ASN1_CTX *c)
{
ASN1_STRING *os=NULL;
BUF_MEM b;
{
ASN1_STRING *os=NULL;
BUF_MEM b;
@@
-318,14
+310,14
@@
static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c)
if (!asn1_Finish(c)) goto err;
a->length=num;
if (!asn1_Finish(c)) goto err;
a->length=num;
- if (a->data != NULL)
F
ree(a->data);
+ if (a->data != NULL)
OPENSSL_f
ree(a->data);
a->data=(unsigned char *)b.data;
if (os != NULL) ASN1_STRING_free(os);
return(1);
err:
a->data=(unsigned char *)b.data;
if (os != NULL) ASN1_STRING_free(os);
return(1);
err:
- ASN1err(ASN1_F_ASN1_COLLATE_PRIM
A
TIVE,c->error);
+ ASN1err(ASN1_F_ASN1_COLLATE_PRIM
I
TIVE,c->error);
if (os != NULL) ASN1_STRING_free(os);
if (os != NULL) ASN1_STRING_free(os);
- if (b.data != NULL)
F
ree(b.data);
+ if (b.data != NULL)
OPENSSL_f
ree(b.data);
return(0);
}
return(0);
}