Skip to content

Increase IPSIZE for IPv6 compatibility.#3259

Merged
chemamartinez merged 2 commits intowazuh:3.10from
aquerubin:ipv6-ipsize
Jul 1, 2019
Merged

Increase IPSIZE for IPv6 compatibility.#3259
chemamartinez merged 2 commits intowazuh:3.10from
aquerubin:ipv6-ipsize

Conversation

@aquerubin
Copy link
Copy Markdown
Contributor

Increase IPSIZE to the larger Socket API (RFC 3493) length for IPv6 compatibility.

@AdriiiPRodri
Copy link
Copy Markdown
Contributor

Hi @aquerubin ,

thank you very much for your time and advice, we have to assess whether or not we should introduce this change because this may generate that throughout the Wazuh code the memory used by the system could increase greatly.

In any case we will evaluate your proposal, thank you

@aquerubin
Copy link
Copy Markdown
Contributor Author

aquerubin commented May 15, 2019 via email

@chemamartinez chemamartinez added this to the 21st week milestone May 20, 2019
@chemamartinez
Copy link
Copy Markdown
Contributor

Hi @aquerubin,

Thank you for your contribution, IPv6 compatibility is an important goal for us.

We are going to include these changes into a release project and will be merged ASAP.

Regards.

@aquerubin
Copy link
Copy Markdown
Contributor Author

aquerubin commented May 20, 2019 via email

@chemamartinez chemamartinez self-requested a review May 21, 2019 10:24
@chemamartinez
Copy link
Copy Markdown
Contributor

Hi again @aquerubin,

I noticed testing the solution a bug in our code that leads to a Segmentation Fault when including your change, here you can see the valgrind report:

==20937== Syscall param socketcall.sendto(msg) points to unaddressable byte(s)
==20937==    at 0x59DFBFB: send (in /usr/lib64/libpthread-2.17.so)
==20937==    by 0x461EF8: OS_SendUnix (os_net.c:490)
==20937==    by 0x40CF77: run_notify (notify.c:142)
==20937==    by 0x4087C1: AgentdStart (agentd.c:187)
==20937==    by 0x409B56: main (main.c:179)
==20937==  Address 0x5fc87d0 is 0 bytes after a block of size 16 alloc'd
==20937==    at 0x4C2B955: calloc (vg_replace_malloc.c:711)
==20937==    by 0x40CEF7: run_notify (notify.c:138)
==20937==    by 0x4087C1: AgentdStart (agentd.c:187)
==20937==    by 0x409B56: main (main.c:179)
==20937==
==20937== Invalid write of size 1
==20937==    at 0x461E51: OS_RecvUnix (os_net.c:470)
==20937==    by 0x40CFCC: run_notify (notify.c:146)
==20937==    by 0x4087C1: AgentdStart (agentd.c:187)
==20937==    by 0x409B56: main (main.c:179)
==20937==  Address 0x5fc87ed is 29 bytes after a block of size 16 in arena "client"

It is caused because agent_ip is allocated with 16 bytes hardcoded here:

os_calloc(16,sizeof(char),agent_ip);

After that, IPSIZE is used to send and receive that IP:

if (OS_SendUnix(sock, agent_ip, IPSIZE) < 0) {

This is solved by allocating the correct size for agent_ip:

os_calloc(IPSIZE,sizeof(char),agent_ip);

And increasing the size of label_ip:

char label_ip[50];

Sorry for the inconveniences, you can include these changes to this PRs. Otherwise, we could do it before merging it.

Best regards,
Chema.

Copy link
Copy Markdown
Contributor

@chemamartinez chemamartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incompatible with

os_calloc(16,sizeof(char),agent_ip);

See more detailed description above.

@aquerubin
Copy link
Copy Markdown
Contributor Author

aquerubin commented May 21, 2019 via email

@chemamartinez chemamartinez modified the milestones: 21st week, 22nd week May 27, 2019
@chemamartinez chemamartinez modified the milestones: 22nd week, 25th week Jun 10, 2019
@chemamartinez chemamartinez changed the base branch from master to 3.10 July 1, 2019 10:26
@chemamartinez
Copy link
Copy Markdown
Contributor

Hi @aquerubin,

Thanks for the requested changes. The error disappeared so I approve the PR.

Thank you again for your contributions!

Best regards.

@chemamartinez chemamartinez self-assigned this Jul 1, 2019
@chemamartinez chemamartinez merged commit 6600f82 into wazuh:3.10 Jul 1, 2019
@aquerubin aquerubin deleted the ipv6-ipsize branch July 5, 2019 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants