Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns.c: Use struct sockaddr in dns_sa_family #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fweimer-rh
Copy link

The allocated object might not be as large as struct sockaddr_storage. Fixes a GCC 13 warning:

dns.c: In function 'dns_ai_setent':
dns.c:679:67: error: array subscript 'struct sockaddr_storage[0]' is partly outside array bounds of 'struct sockaddr[1]' [-Werror=array-bounds=]
  679 | #define dns_sa_family(sa)       (((struct sockaddr_storage *)(sa))->ss_family)
      |                                                                   ^~
dns.c:7465:28: note: object 'sin' of size 16
 7465 |         struct sockaddr_in sin;
      |                            ^~~
dns.c:7466:29: note: object 'sin6' of size 28
 7466 |         struct sockaddr_in6 sin6;
      |                             ^~~~
dns.c:679:67: error: array subscript 'struct sockaddr_storage[0]' is partly outside array bounds of 'struct sockaddr[1]' [-Werror=array-bounds=]
  679 | #define dns_sa_family(sa)       (((struct sockaddr_storage *)(sa))->ss_family)
      |                                                                   ^~
dns.c:7465:28: note: object 'sin' of size 16
 7465 |         struct sockaddr_in sin;
      |                            ^~~
dns.c:7466:29: note: object 'sin6' of size 28
 7466 |         struct sockaddr_in6 sin6;
      |                             ^~~~

(Note: line numbers are off because this patch was developed on Fedora's older version.)

The allocated object might not be as large as struct sockaddr_storage.
Fixes a GCC 13 warning:

dns.c: In function 'dns_ai_setent':
dns.c:679:67: error: array subscript 'struct sockaddr_storage[0]' is partly outside array bounds of 'struct sockaddr[1]' [-Werror=array-bounds=]
  679 | #define dns_sa_family(sa)       (((struct sockaddr_storage *)(sa))->ss_family)
      |                                                                   ^~
dns.c:7465:28: note: object 'sin' of size 16
 7465 |         struct sockaddr_in sin;
      |                            ^~~
dns.c:7466:29: note: object 'sin6' of size 28
 7466 |         struct sockaddr_in6 sin6;
      |                             ^~~~
dns.c:679:67: error: array subscript 'struct sockaddr_storage[0]' is partly outside array bounds of 'struct sockaddr[1]' [-Werror=array-bounds=]
  679 | #define dns_sa_family(sa)       (((struct sockaddr_storage *)(sa))->ss_family)
      |                                                                   ^~
dns.c:7465:28: note: object 'sin' of size 16
 7465 |         struct sockaddr_in sin;
      |                            ^~~
dns.c:7466:29: note: object 'sin6' of size 28
 7466 |         struct sockaddr_in6 sin6;
      |                             ^~~~
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.

1 participant