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
7be9dd86
Commit
7be9dd86
authored
Dec 08, 2023
by
v0-e
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jer: Escapes in strings
parent
0257cf66
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
79 deletions
+95
-79
skeletons/OCTET_STRING_jer.c
skeletons/OCTET_STRING_jer.c
+87
-77
skeletons/RELATIVE-OID_jer.c
skeletons/RELATIVE-OID_jer.c
+1
-0
skeletons/UniversalString_jer.c
skeletons/UniversalString_jer.c
+7
-2
No files found.
skeletons/OCTET_STRING_jer.c
View file @
7be9dd86
...
@@ -54,52 +54,60 @@ static const struct OCTET_STRING__jer_escape_table_s {
...
@@ -54,52 +54,60 @@ static const struct OCTET_STRING__jer_escape_table_s {
int
size
;
int
size
;
}
OCTET_STRING__jer_escape_table
[]
=
{
}
OCTET_STRING__jer_escape_table
[]
=
{
#define OSXET(s) { s, sizeof(s) - 1 }
#define OSXET(s) { s, sizeof(s) - 1 }
OSXET
(
"
\074\156\165\154\057\076
"
),
/* <nul/>
*/
{
0
,
0
},
/* NULL
*/
OSXET
(
"
\074\163\157\150\057\076
"
),
/* <soh/>
*/
{
0
,
0
},
/* Start of header
*/
OSXET
(
"
\074\163\164\170\057\076
"
),
/* <stx/>
*/
{
0
,
0
},
/* Start of text
*/
OSXET
(
"
\074\145\164\170\057\076
"
),
/* <etx/>
*/
{
0
,
0
},
/* End of text
*/
OSXET
(
"
\074\145\157\164\057\076
"
),
/* <eot/>
*/
{
0
,
0
},
/* End of transmission
*/
OSXET
(
"
\074\145\156\161\057\076
"
),
/* <enq/>
*/
{
0
,
0
},
/* Enquiry
*/
OSXET
(
"
\074\141\143\153\057\076
"
),
/* <ack/>
*/
{
0
,
0
},
/* Ack
*/
OSXET
(
"
\074\142\145\154\057\076
"
),
/* <bel/>
*/
{
0
,
0
},
/* Bell
*/
OSXET
(
"
\
074\142\163\057\076
"
),
/* <bs/>
*/
OSXET
(
"
\
134\142
"
),
/* \b
*/
OSXET
(
"
\
011
"
),
/* \t */
OSXET
(
"
\
134\164
"
),
/* \t */
OSXET
(
"
\
012
"
),
/* \n */
OSXET
(
"
\
134\156
"
),
/* \n */
OSXET
(
"
\074\166\164\057\076
"
),
/* <vt/>
*/
{
0
,
0
},
/* Vertical tab
*/
OSXET
(
"
\
074\146\146\057\076
"
),
/* <ff/>
*/
OSXET
(
"
\
134\146
"
),
/* \f
*/
OSXET
(
"
\
015
"
),
/* \r */
OSXET
(
"
\
134\162
"
),
/* \r */
OSXET
(
"
\074\163\157\057\076
"
),
/* <so/>
*/
{
0
,
0
},
/* Shift out
*/
OSXET
(
"
\074\163\151\057\076
"
),
/* <si/>
*/
{
0
,
0
},
/* Shift in
*/
OSXET
(
"
\074\144\154\145\057\076
"
),
/* <dle/>
*/
{
0
,
0
},
/* Data link escape
*/
OSXET
(
"
\074\144\143\061\057\076
"
),
/* <de1/>
*/
{
0
,
0
},
/* Device control 1
*/
OSXET
(
"
\074\144\143\062\057\076
"
),
/* <de2/>
*/
{
0
,
0
},
/* Device control 2
*/
OSXET
(
"
\074\144\143\063\057\076
"
),
/* <de3/>
*/
{
0
,
0
},
/* Device control 3
*/
OSXET
(
"
\074\144\143\064\057\076
"
),
/* <de4/>
*/
{
0
,
0
},
/* Device control 4
*/
OSXET
(
"
\074\156\141\153\057\076
"
),
/* <nak/>
*/
{
0
,
0
},
/* Negative ack
*/
OSXET
(
"
\074\163\171\156\057\076
"
),
/* <syn/>
*/
{
0
,
0
},
/* Synchronous idle
*/
OSXET
(
"
\074\145\164\142\057\076
"
),
/* <etb/>
*/
{
0
,
0
},
/* End of transmission block
*/
OSXET
(
"
\074\143\141\156\057\076
"
),
/* <can/>
*/
{
0
,
0
},
/* Cancel
*/
OSXET
(
"
\074\145\155\057\076
"
),
/* <em/>
*/
{
0
,
0
},
/* End of medium
*/
OSXET
(
"
\074\163\165\142\057\076
"
),
/* <sub/>
*/
{
0
,
0
},
/* Substitute
*/
OSXET
(
"
\074\145\163\143\057\076
"
),
/* <esc/>
*/
{
0
,
0
},
/* Escape
*/
OSXET
(
"
\074\151\163\064\057\076
"
),
/* <is4/>
*/
{
0
,
0
},
/* File separator
*/
OSXET
(
"
\074\151\163\063\057\076
"
),
/* <is3/>
*/
{
0
,
0
},
/* Group separator
*/
OSXET
(
"
\074\151\163\062\057\076
"
),
/* <is2/>
*/
{
0
,
0
},
/* Record separator
*/
OSXET
(
"
\074\151\163\061\057\076
"
),
/* <is1/>
*/
{
0
,
0
},
/* Unit separator
*/
{
0
,
0
},
/* " " */
{
0
,
0
},
/* " " */
{
0
,
0
},
/* ! */
{
0
,
0
},
/* ! */
{
0
,
0
},
/* \" */
OSXET
(
"
\134\042
"
),
/* \" */
{
0
,
0
},
/* # */
{
0
,
0
},
/* # */
{
0
,
0
},
/* $ */
{
0
,
0
},
/* $ */
{
0
,
0
},
/* % */
{
0
,
0
},
/* % */
OSXET
(
"
\046\141\155\160\073
"
),
/* & */
{
0
,
0
},
/* & */
{
0
,
0
},
/* ' */
{
0
,
0
},
/* ' */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* ()*+,-./ */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* ()*+,-./ */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* 01234567 */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* 01234567 */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* 89:; */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* 89:; */
OSXET
(
"
\046\154\164\073
"
),
/* < */
{
0
,
0
},
/* < */
{
0
,
0
},
/* = */
{
0
,
0
},
/* = */
OSXET
(
"
\046\147\164\073
"
),
/* > */
{
0
,
0
},
/* > */
{
0
,
0
},
/* ? */
{
0
,
0
},
/* @ */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* ABCDEFGH */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* IJKLMNOP */
{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},{
0
,
0
},
/* QRSTUVWX */
{
0
,
0
},{
0
,
0
},
/* YZ */
{
0
,
0
},
/* [ */
OSXET
(
"
\134\134
"
),
/* \\ */
};
};
static
int
static
int
...
@@ -166,7 +174,7 @@ OCTET_STRING_encode_jer_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -166,7 +174,7 @@ OCTET_STRING_encode_jer_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
int
s_len
;
/* Special encoding sequence length */
int
s_len
;
/* Special encoding sequence length */
/*
/*
* Escape certain characters
: X.680/11.15
* Escape certain characters
*/
*/
if
(
ch
<
sizeof
(
OCTET_STRING__jer_escape_table
)
if
(
ch
<
sizeof
(
OCTET_STRING__jer_escape_table
)
/
sizeof
(
OCTET_STRING__jer_escape_table
[
0
])
/
sizeof
(
OCTET_STRING__jer_escape_table
[
0
])
...
@@ -213,6 +221,7 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, const void *chunk_b
...
@@ -213,6 +221,7 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, const void *chunk_b
break
;
break
;
}
}
}
}
--
pend
;
for
(;
pend
>=
p
;
--
pend
)
{
for
(;
pend
>=
p
;
--
pend
)
{
if
(
*
pend
==
CQUOTE
)
if
(
*
pend
==
CQUOTE
)
break
;
break
;
...
@@ -269,7 +278,7 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, const void *chunk_b
...
@@ -269,7 +278,7 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, const void *chunk_b
if
(
have_more
)
{
if
(
have_more
)
{
/*
/*
* Partial specification is fine,
* Partial specification is fine,
* because no more more P
X
ER_TEXT data is available.
* because no more more P
J
ER_TEXT data is available.
*/
*/
*
buf
++
=
clv
<<
4
;
*
buf
++
=
clv
<<
4
;
chunk_stop
=
p
;
chunk_stop
=
p
;
...
@@ -329,7 +338,7 @@ OS__strtoent(int base, const char *buf, const char *end, int32_t *ret_value) {
...
@@ -329,7 +338,7 @@ OS__strtoent(int base, const char *buf, const char *end, int32_t *ret_value) {
}
}
/*
/*
* Convert from the plain UTF-8 format
, expanding entity references: "2 < 3"
* Convert from the plain UTF-8 format
*/
*/
static
ssize_t
static
ssize_t
OCTET_STRING__convert_entrefs
(
void
*
sptr
,
const
void
*
chunk_buf
,
OCTET_STRING__convert_entrefs
(
void
*
sptr
,
const
void
*
chunk_buf
,
...
@@ -346,6 +355,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
...
@@ -346,6 +355,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
break
;
break
;
}
}
}
}
--
pend
;
for
(;
pend
>=
p
;
--
pend
)
{
for
(;
pend
>=
p
;
--
pend
)
{
if
(
*
pend
==
CQUOTE
)
if
(
*
pend
==
CQUOTE
)
break
;
break
;
...
@@ -367,7 +377,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
...
@@ -367,7 +377,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
int
ch
=
*
(
const
unsigned
char
*
)
p
;
int
ch
=
*
(
const
unsigned
char
*
)
p
;
int
len
;
/* Length of the rest of the chunk */
int
len
;
/* Length of the rest of the chunk */
if
(
ch
!=
0x
26
/* '&
' */
)
{
if
(
ch
!=
0x
5c
/* '\
' */
)
{
*
buf
++
=
ch
;
*
buf
++
=
ch
;
continue
;
/* That was easy... */
continue
;
/* That was easy... */
}
}
...
@@ -376,8 +386,10 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
...
@@ -376,8 +386,10 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
* Process entity reference.
* Process entity reference.
*/
*/
len
=
chunk_size
-
(
p
-
(
const
char
*
)
chunk_buf
);
len
=
chunk_size
-
(
p
-
(
const
char
*
)
chunk_buf
);
if
(
len
==
1
/* "&" */
)
goto
want_more
;
if
(
len
==
1
/* "\" */
)
goto
want_more
;
if
(
p
[
1
]
==
0x23
/* '#' */
)
{
switch
(
p
[
1
])
{
case
0x75
:
/* 'u' */
;
const
char
*
pval
;
/* Pointer to start of digits */
const
char
*
pval
;
/* Pointer to start of digits */
int32_t
val
=
0
;
/* Entity reference value */
int32_t
val
=
0
;
/* Entity reference value */
int
base
;
int
base
;
...
@@ -425,43 +437,41 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
...
@@ -425,43 +437,41 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
*
buf
++
=
0x80
|
((
val
>>
6
)
&
0x3f
);
*
buf
++
=
0x80
|
((
val
>>
6
)
&
0x3f
);
*
buf
++
=
0x80
|
((
val
&
0x3f
));
*
buf
++
=
0x80
|
((
val
&
0x3f
));
}
}
}
else
{
break
;
/*
case
0x22
:
/* " */
* Ugly, limited parsing of & > <
*
buf
++
=
0x22
;
*/
++
p
;
char
*
sc
=
(
char
*
)
memchr
(
p
,
0x3b
,
len
>
5
?
5
:
len
);
break
;
if
(
!
sc
)
goto
want_more
;
case
0x5c
:
/* \ */
if
((
sc
-
p
)
==
4
*
buf
++
=
0x5c
;
&&
p
[
1
]
==
0x61
/* 'a' */
++
p
;
&&
p
[
2
]
==
0x6d
/* 'm' */
break
;
&&
p
[
3
]
==
0x70
/* 'p' */
)
{
case
0x62
:
/* b */
*
buf
++
=
0x26
;
*
buf
++
=
0x08
;
p
=
sc
;
++
p
;
continue
;
break
;
}
case
0x66
:
/* f */
if
((
sc
-
p
)
==
3
)
{
*
buf
++
=
0x0c
;
if
(
p
[
1
]
==
0x6c
)
{
++
p
;
*
buf
=
0x3c
;
/* '<' */
break
;
}
else
if
(
p
[
1
]
==
0x67
)
{
case
0x6e
:
/* n */
*
buf
=
0x3e
;
/* '>' */
*
buf
++
=
0x0a
;
}
else
{
++
p
;
/* Unsupported entity reference */
break
;
*
buf
++
=
ch
;
case
0x72
:
/* r */
continue
;
*
buf
++
=
0x0d
;
}
++
p
;
if
(
p
[
2
]
!=
0x74
)
{
break
;
case
0x74
:
/* t */
*
buf
++
=
0x09
;
++
p
;
break
;
default:
/* Unsupported entity reference */
/* Unsupported entity reference */
*
buf
++
=
ch
;
*
buf
++
=
ch
;
++
p
;
continue
;
continue
;
}
}
buf
++
;
p
=
sc
;
continue
;
}
/* Unsupported entity reference */
*
buf
++
=
ch
;
}
continue
;
continue
;
want_more:
want_more:
if
(
have_more
)
{
if
(
have_more
)
{
...
@@ -485,7 +495,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
...
@@ -485,7 +495,7 @@ OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
}
}
/*
/*
* Decode OCTET STRING from the
XML element's body
.
* Decode OCTET STRING from the
JSON element's value
.
*/
*/
static
asn_dec_rval_t
static
asn_dec_rval_t
OCTET_STRING__decode_jer
(
OCTET_STRING__decode_jer
(
...
...
skeletons/RELATIVE-OID_jer.c
View file @
7be9dd86
...
@@ -29,6 +29,7 @@ RELATIVE_OID__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -29,6 +29,7 @@ RELATIVE_OID__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
break
;
break
;
}
}
}
}
--
chunk_end
;
for
(;
chunk_end
>=
p
;
--
chunk_end
)
{
for
(;
chunk_end
>=
p
;
--
chunk_end
)
{
if
(
*
chunk_end
==
CQUOTE
)
if
(
*
chunk_end
==
CQUOTE
)
break
;
break
;
...
...
skeletons/UniversalString_jer.c
View file @
7be9dd86
...
@@ -71,6 +71,7 @@ UniversalString_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -71,6 +71,7 @@ UniversalString_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
UniversalString_t
*
st
=
(
const
UniversalString_t
*
)
sptr
;
const
UniversalString_t
*
st
=
(
const
UniversalString_t
*
)
sptr
;
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
ssize_t
ro_encoded
=
0
;
(
void
)
ilevel
;
(
void
)
ilevel
;
(
void
)
flags
;
(
void
)
flags
;
...
@@ -78,8 +79,12 @@ UniversalString_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -78,8 +79,12 @@ UniversalString_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
if
(
!
st
||
!
st
->
buf
)
if
(
!
st
||
!
st
->
buf
)
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
er
.
encoded
=
UniversalString__dump
(
st
,
cb
,
app_key
);
ASN__CALLBACK
(
"
\"
"
,
1
);
if
(
er
.
encoded
<
0
)
ASN__ENCODE_FAILED
;
ro_encoded
=
UniversalString__dump
(
st
,
cb
,
app_key
);
if
(
ro_encoded
<
0
)
goto
cb_failed
;
er
.
encoded
+=
ro_encoded
;
ASN__CALLBACK
(
"
\"
"
,
1
);
cb_failed:
ASN__ENCODED_OK
(
er
);
ASN__ENCODED_OK
(
er
);
}
}
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