Commit f7982283 authored by Lev Walkin's avatar Lev Walkin

fix: There must be no content in self-terminating <NULL/> tag.

parent cad560ae
...@@ -161,10 +161,7 @@ BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun ...@@ -161,10 +161,7 @@ BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
} }
return XPBD_BODY_CONSUMED; return XPBD_BODY_CONSUMED;
} else { } else {
if(xer_is_whitespace(chunk_buf, chunk_size)) return XPBD_BROKEN_ENCODING;
return XPBD_NOT_BODY_IGNORE;
else
return XPBD_BROKEN_ENCODING;
} }
} }
......
...@@ -74,10 +74,13 @@ NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b ...@@ -74,10 +74,13 @@ NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b
(void)td; (void)td;
(void)sptr; (void)sptr;
if(xer_is_whitespace(chunk_buf, chunk_size)) /*
return XPBD_BODY_CONSUMED; * There must be no content in self-terminating <NULL/> tag.
else */
if(chunk_size)
return XPBD_BROKEN_ENCODING; return XPBD_BROKEN_ENCODING;
else
return XPBD_BODY_CONSUMED;
} }
asn_dec_rval_t asn_dec_rval_t
......
...@@ -186,9 +186,10 @@ static ssize_t ...@@ -186,9 +186,10 @@ static ssize_t
xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size, int have_more) { xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size, int have_more) {
struct xdp_arg_s *arg = (struct xdp_arg_s *)key; struct xdp_arg_s *arg = (struct xdp_arg_s *)key;
enum xer_pbd_rval bret; enum xer_pbd_rval bret;
size_t lead_wsp_size;
if(arg->decoded_something) { if(arg->decoded_something) {
if(xer_is_whitespace(chunk_buf, chunk_size)) { if(xer_whitespace_span(chunk_buf, chunk_size) == chunk_size) {
/* /*
* Example: * Example:
* "<INTEGER>123<!--/--> </INTEGER>" * "<INTEGER>123<!--/--> </INTEGER>"
...@@ -215,6 +216,10 @@ xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size, ...@@ -215,6 +216,10 @@ xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size,
return -1; return -1;
} }
lead_wsp_size = xer_whitespace_span(chunk_buf, chunk_size);
chunk_buf += lead_wsp_size;
chunk_size -= lead_wsp_size;
bret = arg->prim_body_decoder(arg->type_descriptor, bret = arg->prim_body_decoder(arg->type_descriptor,
arg->struct_key, chunk_buf, chunk_size); arg->struct_key, chunk_buf, chunk_size);
switch(bret) { switch(bret) {
...@@ -227,7 +232,7 @@ xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size, ...@@ -227,7 +232,7 @@ xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size,
arg->decoded_something = 1; arg->decoded_something = 1;
/* Fall through */ /* Fall through */
case XPBD_NOT_BODY_IGNORE: /* Safe to proceed further */ case XPBD_NOT_BODY_IGNORE: /* Safe to proceed further */
return chunk_size; return lead_wsp_size + chunk_size;
} }
return -1; return -1;
......
...@@ -316,8 +316,8 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, ...@@ -316,8 +316,8 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx,
} }
int size_t
xer_is_whitespace(const void *chunk_buf, size_t chunk_size) { xer_whitespace_span(const void *chunk_buf, size_t chunk_size) {
const char *p = (const char *)chunk_buf; const char *p = (const char *)chunk_buf;
const char *pend = p + chunk_size; const char *pend = p + chunk_size;
...@@ -330,12 +330,13 @@ xer_is_whitespace(const void *chunk_buf, size_t chunk_size) { ...@@ -330,12 +330,13 @@ xer_is_whitespace(const void *chunk_buf, size_t chunk_size) {
* SPACE (32) * SPACE (32)
*/ */
case 0x09: case 0x0a: case 0x0d: case 0x20: case 0x09: case 0x0a: case 0x0d: case 0x20:
break; continue;
default: default:
return 0; break;
} }
break;
} }
return 1; /* All whitespace */ return (p - (const char *)chunk_buf);
} }
/* /*
......
...@@ -87,12 +87,11 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, ...@@ -87,12 +87,11 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size,
const char *need_tag); const char *need_tag);
/* /*
* Check whether this buffer consists of entirely XER whitespace characters. * Get the number of bytes consisting entirely of XER whitespace characters.
* RETURN VALUES: * RETURN VALUES:
* 1: Whitespace or empty string * >=0: Number of whitespace characters in the string.
* 0: Non-whitespace
*/ */
int xer_is_whitespace(const void *chunk_buf, size_t chunk_size); size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size);
/* /*
* Skip the series of anticipated extensions. * Skip the series of anticipated extensions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment