chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a snprinf wrapper which checks that the buffer was big enough
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 891182a35b70d4460aa2082914753090305f6621..11cab6dcf1710f590b2a879f019f274ead1e6020 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-4248,6
+4248,11
@@
bool hostname_is_valid(const char *s) {
if (isempty(s))
return false;
if (isempty(s))
return false;
+ /* Doesn't accept empty hostnames, hostnames with trailing or
+ * leading dots, and hostnames with multiple dots in a
+ * sequence. Also ensures that the length stays below
+ * HOST_NAME_MAX. */
+
for (p = s, dot = true; *p; p++) {
if (*p == '.') {
if (dot)
for (p = s, dot = true; *p; p++) {
if (*p == '.') {
if (dot)