On Tue, Nov 03, 2009 at 10:09:04AM +0100, Martin Kaiser via RT wrote:
> If the parameter has neither ln nor sn, I suggest that -1 is returned.
>
> The attached short patch against today's snapshot fixes this problem
>
Thinking about this again, would it make sense to add an error to the
queue like the patch below?
Best regards,
Martin
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index e999ef7..fd98769 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -466,7 +466,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
{
int i,n=0,len,nid, first, use_bn;
- BIGNUM *bl;
+ BIGNUM *bl=NULL;
unsigned long l;
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
@@ -483,6 +483,11 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *
s=OBJ_nid2ln(nid);
if (s == NULL)
s=OBJ_nid2sn(nid);
+ if (s == NULL)
+ {
+ OBJerr(OBJ_F_OBJ_OBJ2TXT,OBJ_R_UNKNOWN_NID_NAME);
+ goto err;
+ }
if (buf)
BUF_strlcpy(buf,s,buf_len);
n=strlen(s);
@@ -494,7 +499,6 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a
p=a->data;
first = 1;
- bl = NULL;
while (len > 0)
{
diff --git a/crypto/objects/objects.h b/crypto/objects/objects.h
index bd0ee52..ab43d9d 100644
--- a/crypto/objects/objects.h
+++ b/crypto/objects/objects.h
@@ -1127,10 +1127,12 @@ void ERR_load_OBJ_strings(void);
#define OBJ_F_OBJ_NID2LN 102
#define OBJ_F_OBJ_NID2OBJ 103
#define OBJ_F_OBJ_NID2SN 104
+#define OBJ_F_OBJ_OBJ2TXT 105
/* Reason codes. */
#define OBJ_R_MALLOC_FAILURE 100
#define OBJ_R_UNKNOWN_NID 101
+#define OBJ_R_UNKNOWN_NID_NAME 102
#ifdef __cplusplus
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [email protected]