Skip to content

Windows DNS SD : add port knocking like other implementations#801

Merged
pcercuei merged 1 commit intomasterfrom
rgetz-dnssd-add-port-knocking-to-win
Mar 4, 2022
Merged

Windows DNS SD : add port knocking like other implementations#801
pcercuei merged 1 commit intomasterfrom
rgetz-dnssd-add-port-knocking-to-win

Conversation

@rgetz
Copy link
Copy Markdown
Contributor

@rgetz rgetz commented Feb 23, 2022

Both the Linux and Mac implemations of DNS SD ensures something is there
before passing the host information up the stack. The Windows
implemnation was missing this, so add it.

Fix #559

Signed-off-by: Robin Getz robin.getz@analog.com

@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Feb 23, 2022

create a draft, so I can test the Windows builds.

@rgetz rgetz force-pushed the rgetz-dnssd-add-port-knocking-to-win branch 4 times, most recently from 7ea9436 to a0621b6 Compare February 27, 2022 04:48
@rgetz rgetz marked this pull request as ready for review February 27, 2022 05:02
@rgetz rgetz requested review from adisuciu and pcercuei February 27, 2022 05:02
@rgetz rgetz force-pushed the rgetz-dnssd-add-port-knocking-to-win branch from a0621b6 to 763a980 Compare February 28, 2022 21:42
@pcercuei pcercuei self-requested a review February 28, 2022 23:26
@rgetz rgetz force-pushed the rgetz-dnssd-add-port-knocking-to-win branch 2 times, most recently from 5d2254e to 1c7b07b Compare March 2, 2022 15:17
@pcercuei pcercuei self-requested a review March 2, 2022 15:48
@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Mar 2, 2022

with these changes - just downloading and testing on windows now...

@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Mar 2, 2022

just tested the windows VS-2019 build, and it seems to work correctly, and not manifest the issues reported earlier.

Thanks

@pcercuei pcercuei self-requested a review March 3, 2022 10:09
@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Mar 3, 2022

This should probably be called only if ret == 0. Because if ret < 0 that would cause use-after-free errors, when the caller function calls dnssd_free_all_discovery_data(ddata).

I think (but am happy to be corrected), as long as d or ddata points to zero'd memory (which it does via zalloc) it should be fine to call free (null pointer). Correct?

@pcercuei
Copy link
Copy Markdown
Contributor

pcercuei commented Mar 3, 2022

I think (but am happy to be corrected), as long as d or ddata points to zero'd memory (which it does via zalloc) it should be fine to call free (null pointer). Correct?

It is fine to call free(NULL), but this is not what would happen here. After dnssd_free_all_discovery_data(ddata) is called, the ddata pointer is invalid and not NULL, so a second call to dnssd_free_all_discovery_data() would cause use-after-free.

Both the Linux and Mac implemations of DNS SD ensures something is there
before passing the host information up the stack. The Windows
implemnation was missing this, so add it. Add locking since it's needed
by those functions.

Fix #559

Signed-off-by: Robin Getz <robin.getz@analog.com>
@rgetz rgetz force-pushed the rgetz-dnssd-add-port-knocking-to-win branch from 1c7b07b to d1b0a80 Compare March 3, 2022 16:03
@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Mar 3, 2022

dnssd_free_all_discovery_data(ddata) is called

yeah - sorry - I missed that I had not removed all the dnssd_free_all_discovery_data(ddata) calls. I was commenting on what I thought the code was - not what I had actually done... Sorry.

-Robin

@pcercuei
Copy link
Copy Markdown
Contributor

pcercuei commented Mar 3, 2022

Note that in your new commit (and actually in libiio master as well), if open_client_sockets() returns 0, the ddata is never freed. I think it would make sense to make open_client_sockets() return an error instead of 0 if it couldn't open any socket.

@rgetz
Copy link
Copy Markdown
Contributor Author

rgetz commented Mar 3, 2022

if open_client_sockets() returns 0, the ddata is never freed.

dns_sd.c:dnssd_context_scan() calls dnssd_find_hosts()

If open_client_sockets() returns 0, it drops down to out_free_buffer; which will return with a 0 code.

dns_sd.c:dnssd_context_scan() will try to iterate on things:
for (ndata = ddata; ndata->next != NULL; ndata = ndata->next)

and since it is all null, (via zalloc), it should drop down to dnssd_free_all_discovery_data(ddata);

shouldn't it?

@pcercuei
Copy link
Copy Markdown
Contributor

pcercuei commented Mar 3, 2022

I guess you are right, yes.

@pcercuei pcercuei merged commit 68d1d8a into master Mar 4, 2022
@pcercuei pcercuei deleted the rgetz-dnssd-add-port-knocking-to-win branch March 4, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scan failure on one backend causes failures on all

2 participants