Skip to content

Commit c25a20f

Browse files
committed
iiod: dns-sd: Fix invalid check of hostname vs. "none" string
By doing: strncmp(host, "none", sizeof("none") - 1) We actually only check that the first 4 characters are "none"; as a result, a "none_foobar.local" hostname would match as well. The solution is to match the ending \0 as well: strncmp(host, "none", sizeof("none")) which can be simplified to just strcmp(host, "none") Signed-off-by: Paul Cercueil <[email protected]>
1 parent 5515b11 commit c25a20f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iiod/dns-sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static void start_avahi_thd(struct thread_pool *pool, void *d)
256256
while(true) {
257257
ret = gethostname(host, sizeof(host));
258258
IIO_ERROR("host %s\n", host);
259-
if (ret || !strncmp(host, "none", sizeof("none") - 1))
259+
if (ret || !strcmp(host, "none"))
260260
goto again;
261261

262262
iio_snprintf(label, sizeof(label), "%s%s", IIOD_ON, host);

0 commit comments

Comments
 (0)