Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
190419b2
Commit
190419b2
authored
Oct 25, 2010
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PER decoding of open types fix
parent
ffe79f44
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
3 deletions
+136
-3
asn1c/tests/check-131.-gen-PER.c
asn1c/tests/check-131.-gen-PER.c
+59
-0
skeletons/per_opentype.c
skeletons/per_opentype.c
+5
-2
skeletons/per_support.c
skeletons/per_support.c
+1
-1
tests/131-per-empty-OK.asn1
tests/131-per-empty-OK.asn1
+16
-0
tests/131-per-empty-OK.asn1.-Pgen-PER
tests/131-per-empty-OK.asn1.-Pgen-PER
+55
-0
No files found.
asn1c/tests/check-131.-gen-PER.c
0 → 100644
View file @
190419b2
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "T.h"
#include "per_opentype.h"
int
main
()
{
asn_per_data_t
pd
;
asn_per_outp_t
po
;
asn_dec_rval_t
rv
;
T_t
t
;
T_t
*
t2
=
0
;
size_t
i
;
memset
(
&
po
,
0
,
sizeof
po
);
po
.
buffer
=
po
.
tmpspace
;
po
.
nbits
=
sizeof
(
po
.
tmpspace
)
*
8
;
memset
(
&
t
,
0
,
sizeof
t
);
printf
(
"Checking uper_open_type_put():
\n
"
);
assert
(
0
==
uper_open_type_put
(
&
asn_DEF_T
,
0
,
&
t
,
&
po
));
assert
(
po
.
nbits
==
(
-
1
+
sizeof
(
po
.
tmpspace
))
*
8
);
printf
(
"po{nboff=%d; nbits=%d; buffer=%p; tmpspace=%p}
\n
"
,
po
.
nboff
,
po
.
nbits
,
po
.
buffer
,
po
.
tmpspace
);
/* One byte length and one byte 0x00 */
assert
(
(
po
.
nboff
==
8
&&
po
.
buffer
==
&
po
.
tmpspace
[
1
])
||
(
po
.
nboff
==
0
&&
po
.
buffer
==
&
po
.
tmpspace
[
2
]));
assert
(
po
.
tmpspace
[
0
]
==
0x01
);
assert
(
po
.
tmpspace
[
1
]
==
0x00
);
printf
(
"
\n
Checking uper_open_type_get():
\n
"
);
for
(
i
=
0
;
i
<
16
;
i
++
)
{
FREEMEM
(
t2
);
t2
=
0
;
memset
(
&
pd
,
0
,
sizeof
pd
);
pd
.
buffer
=
po
.
tmpspace
;
pd
.
nboff
=
0
;
pd
.
nbits
=
i
;
rv
=
uper_open_type_get
(
0
,
&
asn_DEF_T
,
0
,
(
void
**
)
&
t2
,
&
pd
);
assert
(
rv
.
code
==
RC_WMORE
);
}
memset
(
&
pd
,
0
,
sizeof
pd
);
pd
.
buffer
=
po
.
tmpspace
;
pd
.
nboff
=
0
;
pd
.
nbits
=
16
;
rv
=
uper_open_type_get
(
0
,
&
asn_DEF_T
,
0
,
(
void
**
)
&
t2
,
&
pd
);
assert
(
rv
.
code
==
RC_OK
);
assert
(
(
pd
.
nboff
==
8
&&
pd
.
buffer
==
&
po
.
tmpspace
[
1
])
||
(
pd
.
nboff
==
16
&&
pd
.
buffer
==
&
po
.
tmpspace
[
0
]));
assert
(
pd
.
nboff
+
pd
.
nbits
==
16
);
return
0
;
}
skeletons/per_opentype.c
View file @
190419b2
...
...
@@ -38,6 +38,8 @@ uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints
for
(
bptr
=
buf
,
toGo
=
size
;
toGo
;)
{
ssize_t
maySave
=
uper_put_length
(
po
,
toGo
);
ASN_DEBUG
(
"Prepending length %d to %s and allowing to save %d"
,
(
int
)
size
,
td
->
name
,
(
int
)
maySave
);
if
(
maySave
<
0
)
break
;
if
(
per_put_many_bits
(
po
,
bptr
,
maySave
*
8
))
break
;
bptr
=
(
char
*
)
bptr
+
maySave
;
...
...
@@ -106,8 +108,9 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
if
(
rv
.
code
==
RC_OK
)
{
/* Check padding validity */
padding
=
spd
.
nbits
-
spd
.
nboff
;
if
(((
rv
.
consumed
==
0
&&
padding
==
8
)
/* X.691#10.1.3 */
||
padding
<
8
)
&&
if
((
padding
<
8
||
/* X.691#10.1.3 */
(
spd
.
nboff
==
0
&&
spd
.
nbits
==
8
&&
spd
.
buffer
==
buf
))
&&
per_get_few_bits
(
&
spd
,
padding
)
==
0
)
{
/* Everything is cool */
FREEMEM
(
buf
);
...
...
skeletons/per_support.c
View file @
190419b2
...
...
@@ -314,7 +314,7 @@ per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) {
ASN_DEBUG
(
"[PER out %d %u/%x (t=%d,o=%d) %x&%x=%x]"
,
obits
,
(
int
)
bits
,
(
int
)
bits
,
po
->
nboff
-
obits
,
off
,
buf
[
0
],
omsk
&
0xff
,
buf
[
0
]
&
omsk
);
po
->
nboff
,
off
,
buf
[
0
],
omsk
&
0xff
,
buf
[
0
]
&
omsk
);
if
(
off
<=
8
)
/* Completely within 1 byte */
po
->
nboff
=
off
,
...
...
tests/131-per-empty-OK.asn1
0 → 100644
View file @
190419b2
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .131
ModulePERLong
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 131 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
T ::= SEQUENCE { } -- Empty sequence
END
tests/131-per-empty-OK.asn1.-Pgen-PER
0 → 100644
View file @
190419b2
/*** <<< INCLUDES [T] >>> ***/
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [T] >>> ***/
typedef struct T {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} T_t;
/*** <<< FUNC-DECLS [T] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_T;
/*** <<< STAT-DEFS [T] >>> ***/
static ber_tlv_tag_t asn_DEF_T_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
sizeof(struct T),
offsetof(struct T, _asn_ctx),
0, /* No top level tags */
0, /* No tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_T = {
"T",
"T",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_uper,
SEQUENCE_encode_uper,
0, /* Use generic outmost tag fetcher */
asn_DEF_T_tags_1,
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
asn_DEF_T_tags_1, /* Same as above */
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
0, 0, /* No members */
&asn_SPC_T_specs_1 /* Additional specs */
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment