Enforce limits on utf8 strings.
This commit is contained in:
+33
-1
@@ -8,6 +8,38 @@
|
||||
|
||||
#include "ChatRequestMessage.h"
|
||||
|
||||
static int
|
||||
memb_chatText_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const UTF8String_t *st = (const UTF8String_t *)sptr;
|
||||
size_t size;
|
||||
|
||||
if(!sptr) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = UTF8String_length(st);
|
||||
if((ssize_t)size < 0) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
"%s: UTF-8: broken encoding (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((size >= 1 && size <= 128)) {
|
||||
/* Constraint check succeeded */
|
||||
return 0;
|
||||
} else {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
"%s: constraint failed (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static asn_TYPE_member_t asn_MBR_ChatRequestMessage_1[] = {
|
||||
{ ATF_NOFLAGS, 0, offsetof(struct ChatRequestMessage, gameId),
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
|
||||
@@ -22,7 +54,7 @@ static asn_TYPE_member_t asn_MBR_ChatRequestMessage_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
|
||||
0,
|
||||
&asn_DEF_UTF8String,
|
||||
0, /* Defer constraints checking to the member type */
|
||||
memb_chatText_constraint_1,
|
||||
0, /* PER is not compiled, use -gen-PER */
|
||||
0,
|
||||
"chatText"
|
||||
|
||||
Reference in New Issue
Block a user