Enforce limits on utf8 strings.

This commit is contained in:
lotodore
2009-07-31 23:29:31 +00:00
parent 6bdb7b4a55
commit 5a86ab9431
8 changed files with 264 additions and 8 deletions
+33 -1
View File
@@ -8,12 +8,44 @@
#include "DialogMessage.h"
static int
memb_notificationText_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_DialogMessage_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct DialogMessage, notificationText),
(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
0,
&asn_DEF_UTF8String,
0, /* Defer constraints checking to the member type */
memb_notificationText_constraint_1,
0, /* PER is not compiled, use -gen-PER */
0,
"notificationText"