From 069397c63ead319d5e237fa1ce16714bb86fc7f7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Jun 2006 21:01:08 +0000 Subject: r16207: Ensure we don't allocate an OID string unless we know we don't have an error. Klocwork #6. Jeremy. (This used to be commit 2c1a2d7b40e7ef353461f97f5c69c2079b5670ab) --- source3/libsmb/asn1.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c index 86a2845192..8c986c9588 100644 --- a/source3/libsmb/asn1.c +++ b/source3/libsmb/asn1.c @@ -340,7 +340,11 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) pstring oid_str; fstring el; - if (!asn1_start_tag(data, ASN1_OID)) return False; + *OID = NULL; + + if (!asn1_start_tag(data, ASN1_OID)) { + return False; + } asn1_read_uint8(data, &b); oid_str[0] = 0; @@ -361,7 +365,9 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_end_tag(data); - *OID = SMB_STRDUP(oid_str); + if (!data->has_error) { + *OID = SMB_STRDUP(oid_str); + } return !data->has_error; } @@ -371,7 +377,9 @@ BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) { char *id; - if (!asn1_read_OID(data, &id)) return False; + if (!asn1_read_OID(data, &id)) { + return False; + } if (strcmp(id, OID) != 0) { data->has_error = True; -- cgit