2 * This program is is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2 if the
4 * License as published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 * @brief Enforce UTF8 encoding in strings.
21 * @copyright 2000,2006 The FreeRADIUS server project
25 #include <freeradius-devel/radiusd.h>
26 #include <freeradius-devel/modules.h>
29 * Reject any non-UTF8 data.
31 static rlm_rcode_t CC_HINT(nonnull) mod_utf8_clean(UNUSED void *instance, REQUEST *request)
37 for (vp = fr_cursor_init(&cursor, &request->packet->vps);
39 vp = fr_cursor_next(&cursor)) {
40 if (vp->da->type != PW_TYPE_STRING) continue;
42 for (i = 0; i < vp->vp_length; i += len) {
43 len = fr_utf8_char(&vp->vp_octets[i]);
44 if (len == 0) return RLM_MODULE_FAIL;
48 return RLM_MODULE_NOOP;
52 * The module name should be the only globally exported symbol.
53 * That is, everything else should be 'static'.
55 * If the module needs to temporarily modify it's instantiation
56 * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE.
57 * The server will then take care of ensuring that the module
60 extern module_t rlm_utf8;
64 RLM_TYPE_THREAD_SAFE, /* type */
66 NULL, /* CONF_PARSER */
67 NULL, /* instantiation */
70 NULL, /* authentication */
71 mod_utf8_clean, /* authorization */
72 mod_utf8_clean, /* preaccounting */
73 NULL, /* accounting */
74 NULL, /* checksimul */
76 NULL, /* post-proxy */