projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ASN1: Fix NULL pointer dereference on stack allocation failure.
[silc.git]
/
lib
/
silcasn1
/
silcasn1.c
diff --git
a/lib/silcasn1/silcasn1.c
b/lib/silcasn1/silcasn1.c
index dfb5cd3ded0c95ac9441ac9ad92a99e01c025745..2e43b49c233631a017cabee0c7b9d07791e643c3 100644
(file)
--- a/
lib/silcasn1/silcasn1.c
+++ b/
lib/silcasn1/silcasn1.c
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 - 200
5
Pekka Riikonen
+ Copyright (C) 2003 - 200
7
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,7
+17,7
@@
*/
*/
-#include "silc
includes
.h"
+#include "silc.h"
#include "silcasn1.h"
#include "silcber.h"
#include "silcasn1.h"
#include "silcber.h"
@@
-53,7
+53,7
@@
SilcBool silc_asn1_init(SilcAsn1 asn1)
asn1->stack2 = silc_stack_alloc(768);
if (!asn1->stack2) {
asn1->stack2 = silc_stack_alloc(768);
if (!asn1->stack2) {
- silc_stack_free(asn1->stack
2
);
+ silc_stack_free(asn1->stack
1
);
return FALSE;
}
return FALSE;
}
@@
-66,15
+66,11
@@
SilcBool silc_asn1_init(SilcAsn1 asn1)
void silc_asn1_uninit(SilcAsn1 asn1)
{
void silc_asn1_uninit(SilcAsn1 asn1)
{
-#if 1
- silc_stack_stats(asn1->stack1);
- silc_stack_stats(asn1->stack2);
-#endif
silc_stack_free(asn1->stack1);
silc_stack_free(asn1->stack2);
}
silc_stack_free(asn1->stack1);
silc_stack_free(asn1->stack2);
}
-#if
def SILC_DIST_INPLACE
+#if
defined(SILC_DEBUG)
/* Returns string representation of a tag */
const char *silc_asn1_tag_name(SilcAsn1Tag tag)
/* Returns string representation of a tag */
const char *silc_asn1_tag_name(SilcAsn1Tag tag)
@@
-88,15
+84,18
@@
const char *silc_asn1_tag_name(SilcAsn1Tag tag)
return "choice";
case SILC_ASN1_TAG_ANY:
return "any";
return "choice";
case SILC_ASN1_TAG_ANY:
return "any";
+ case SILC_ASN1_TAG_ANY_PRIMITIVE:
+ return "any primitive";
case SILC_ASN1_TAG_SEQUENCE_OF:
return "sequence of";
case SILC_ASN1_TAG_SEQUENCE_OF:
return "sequence of";
-
case SILC_ASN1_TAG_SEQUENCE:
return "sequence";
case SILC_ASN1_TAG_SET:
return "set";
case SILC_ASN1_TAG_INTEGER:
return "integer";
case SILC_ASN1_TAG_SEQUENCE:
return "sequence";
case SILC_ASN1_TAG_SET:
return "set";
case SILC_ASN1_TAG_INTEGER:
return "integer";
+ case SILC_ASN1_TAG_SHORT_INTEGER:
+ return "short integer";
case SILC_ASN1_TAG_OID:
return "oid";
case SILC_ASN1_TAG_BOOLEAN:
case SILC_ASN1_TAG_OID:
return "oid";
case SILC_ASN1_TAG_BOOLEAN:
@@
-152,14
+151,17
@@
const char *silc_asn1_tag_name(SilcAsn1Tag tag)
}
return "unknown";
}
}
return "unknown";
}
+#endif /* SILC_DEBUG */
+#ifdef SILC_DIST_TOOLKIT
+#ifdef SILC_DEBUG
/* Dumps the ASN.1 data block into standard output (stdout). */
SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src)
{
SilcBool ret = FALSE;
SilcBerEncoding renc;
/* Dumps the ASN.1 data block into standard output (stdout). */
SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src)
{
SilcBool ret = FALSE;
SilcBerEncoding renc;
- Silc
Asn1Tag
rtag;
+ Silc
UInt32
rtag;
const unsigned char *rdata;
SilcUInt32 rdata_len, len = 0;
SilcBool rindef;
const unsigned char *rdata;
SilcUInt32 rdata_len, len = 0;
SilcBool rindef;
@@
-168,7
+170,7
@@
SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src)
while (silc_buffer_len(src)) {
/* Decode the BER block */
while (silc_buffer_len(src)) {
/* Decode the BER block */
- ret = silc_ber_decode(src, NULL, &renc,
(SilcUInt32 *)
&rtag, &rdata,
+ ret = silc_ber_decode(src, NULL, &renc, &rtag, &rdata,
&rdata_len, &rindef, &len);
if (!ret) {
SILC_LOG_DEBUG(("Error parsing BER block, malformed ASN.1 data"));
&rdata_len, &rindef, &len);
if (!ret) {
SILC_LOG_DEBUG(("Error parsing BER block, malformed ASN.1 data"));
@@
-189,5
+191,5
@@
SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src)
return TRUE;
}
return TRUE;
}
-
-#endif /* SILC_DIST_
INPLACE
*/
+#endif /* SILC_DEBUG */
+#endif /* SILC_DIST_
TOOLKIT
*/