aboutsummaryrefslogtreecommitdiffstats
path: root/src/names.c
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2019-10-30 17:15:23 +0100
committerJose Bollo <jose.bollo@iot.bzh>2019-11-04 12:03:31 +0100
commit195d93caaec446b2cbca2059b41803498a0b30c9 (patch)
tree31e9ec5ca099d7261e9fd82e9008ab64eb3b82af /src/names.c
parent3ab6b486ca043d237b89fe530cb10ca89b489344 (diff)
Improve management of agent names
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/names.c')
-rw-r--r--src/names.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/names.c b/src/names.c
index f9a7817..089df5f 100644
--- a/src/names.c
+++ b/src/names.c
@@ -31,20 +31,21 @@
* @param name the name to check
* @return the length of the name or zero if invalid
*/
-size_t
+uint8_t
agent_check_name(
const char *name
) {
char c;
- size_t length = 0;
+ uint8_t length = 0;
+
if (name) {
while ((c = name[length])) {
- if (length > UINT8_MAX
- || (!isalnum(c) && !strchr("@_-$", c))) {
+ if (!isalnum(c) && !strchr("@_-$", c)) {
length = 0;
break;
}
- length++;
+ if (!++length)
+ break;
}
}
return length;