Skip to content

Commit

Permalink
refactored tagging support
Browse files Browse the repository at this point in the history
  • Loading branch information
vlm committed Sep 10, 2004
1 parent fa30126 commit 906654e
Show file tree
Hide file tree
Showing 52 changed files with 1,047 additions and 252 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

0.9.4: 2004-Sep-07
0.9.4: 2004-Sep-10

* More support for recursive type definitions.
* Explicit support for ANY type decoding.
* Refactored tags processing code.
* Fixed constraints checking code: non-exploitable buffer overflow.
(Severity: medium, Security impact: low)

0.9.3: 2004-Sep-07

Expand Down
5 changes: 2 additions & 3 deletions asn1c/tests/check-43.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
#include <assert.h>

#include <Test-structure-1.h>
#include <Sets.h>
#include <Choice-1.h>

int
main(int ac, char **av) {
Test_structure_1_t ts1;
Sets_t s1;
Choice_1_t cs1;

(void)ac; /* Unused argument */
(void)av; /* Unused argument */

memset(&ts1, 0, sizeof(ts1));
memset(&s1, 0, sizeof(s1));

/*
* No plans to fill it up: just checking whether it compiles or not.
Expand Down
115 changes: 115 additions & 0 deletions asn1c/tests/check-65.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>

#include <T.h>
#include <T1.h>

uint8_t buf1[] = {
32 | ((2 << 6) + 2), /* [2], constructed */
8,
32 | ((2 << 6) + 3), /* [3], constructed */
6,
32 | ((2 << 6) + 4), /* [4], constructed */
4,
0 | ((2 << 6) + 6), /* [6], primitive */
2,
0x91,
0x92
};

uint8_t buf2[] = {

32 | ((2 << 6) + 0), /* [0], constructed */
22,

32 | ((2 << 6) + 1), /* [1], constructed */
6,
32 | ((2 << 6) + 4), /* [4], constructed */
4,
0 | ((2 << 6) + 6), /* [6], primitive */
2,
0x91,
0x92,

32 | ((2 << 6) + 2), /* [2], constructed */
6,
32 | ((2 << 6) + 4), /* [4], constructed */
4,
0 | ((2 << 6) + 6), /* [6], primitive */
2,
0x91,
0x92,

32 | ((2 << 6) + 3), /* [3], constructed */
4,
0 | ((2 << 6) + 6), /* [6], primitive */
2,
0x91,
0x92,

};

static void
check_1(int is_ok, uint8_t *buf, int size, size_t consumed) {
asn1_TYPE_descriptor_t *td = &asn1_DEF_T1;
ber_dec_rval_t rval;
T1_t t, *tp;

tp = memset(&t, 0, sizeof(t));

fprintf(stderr, "Buf %p\n", buf);
rval = ber_decode(td, (void **)&tp, buf, size);
fprintf(stderr, "Returned code %d, consumed %d\n",
(int)rval.code, (int)rval.consumed);

if(is_ok) {
assert(rval.code == RC_OK);
assert(rval.consumed == consumed);
} else {
if(rval.code == RC_OK) {
}
assert(rval.consumed <= consumed);
}
}

static void
check_2(int is_ok, uint8_t *buf, int size, size_t consumed) {
asn1_TYPE_descriptor_t *td = &asn1_DEF_T;
ber_dec_rval_t rval;
T_t t, *tp;

tp = memset(&t, 0, sizeof(t));

fprintf(stderr, "Buf %p\n", buf);
rval = ber_decode(td, (void **)&tp, buf, size);
fprintf(stderr, "Returned code %d, consumed %d\n",
(int)rval.code, (int)rval.consumed);

if(is_ok) {
assert(rval.code == RC_OK);
assert(rval.consumed == consumed);
} else {
if(rval.code == RC_OK) {
}
assert(rval.consumed <= consumed);
}
}

int
main(int ac, char **av) {

(void)ac; /* Unused argument */
(void)av; /* Unused argument */

check_1(1, buf1, sizeof(buf1), sizeof(buf1));
check_1(0, buf1, sizeof(buf1) - 1, sizeof(buf1) - 1);

check_2(1, buf2, sizeof(buf2), sizeof(buf2));
check_2(0, buf2, sizeof(buf2) - 1, sizeof(buf2) - 1);

return 0;
}
Loading

0 comments on commit 906654e

Please sign in to comment.