diff options
author | Susant Sahani <susant@redhat.com> | 2017-02-28 16:53:58 +0530 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-17 17:58:36 +0200 |
commit | eeb58b12cdce99bcbc654a9b89f9e7622ad3eb04 (patch) | |
tree | 778914e856636c3f92947873565864745f18a6ba /src/basic/socket-util.c | |
parent | a1139e6018cccf1f5987e3b95bc708dae6f53767 (diff) |
socket-util: introduce address_label_valid
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r-- | src/basic/socket-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 9ec901261..68773d54c 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -904,6 +904,26 @@ bool ifname_valid(const char *p) { return true; } +bool address_label_valid(const char *p) { + + if (isempty(p)) + return false; + + if (strlen(p) >= IFNAMSIZ) + return false; + + while (*p) { + if ((uint8_t) *p >= 127U) + return false; + + if ((uint8_t) *p <= 31U) + return false; + p++; + } + + return true; +} + int getpeercred(int fd, struct ucred *ucred) { socklen_t n = sizeof(struct ucred); struct ucred u; |