Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.8 KiB

8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. From 6843d3c05dedd4609b3ad43eb17983b68a85e710 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <busterb@gmail.com>
  3. Date: Tue, 30 Dec 2014 09:02:50 -0600
  4. Subject: [PATCH 03/13] conditionally fill in sin_len/sin6_len if they exist
  5. ---
  6. src/usr.sbin/ntpd/config.c | 8 ++++++++
  7. src/usr.sbin/ntpd/parse.y | 8 +++++---
  8. 2 files changed, 13 insertions(+), 3 deletions(-)
  9. diff --git a/src/usr.sbin/ntpd/config.c b/src/usr.sbin/ntpd/config.c
  10. index e3eeed3d67..a84635ab77 100644
  11. --- a/src/usr.sbin/ntpd/config.c
  12. +++ b/src/usr.sbin/ntpd/config.c
  13. @@ -72,7 +72,9 @@ host_v4(const char *s)
  14. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  15. fatal(NULL);
  16. sa_in = (struct sockaddr_in *)&h->ss;
  17. +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  18. sa_in->sin_len = sizeof(struct sockaddr_in);
  19. +#endif
  20. sa_in->sin_family = AF_INET;
  21. sa_in->sin_addr.s_addr = ina.s_addr;
  22. @@ -94,7 +96,9 @@ host_v6(const char *s)
  23. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  24. fatal(NULL);
  25. sa_in6 = (struct sockaddr_in6 *)&h->ss;
  26. +#ifdef SIN6_LEN
  27. sa_in6->sin6_len = sizeof(struct sockaddr_in6);
  28. +#endif
  29. sa_in6->sin6_family = AF_INET6;
  30. memcpy(&sa_in6->sin6_addr,
  31. &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
  32. @@ -156,12 +160,16 @@ host_dns(const char *s, struct ntp_addr **hn)
  33. h->ss.ss_family = res->ai_family;
  34. if (res->ai_family == AF_INET) {
  35. sa_in = (struct sockaddr_in *)&h->ss;
  36. +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  37. sa_in->sin_len = sizeof(struct sockaddr_in);
  38. +#endif
  39. sa_in->sin_addr.s_addr = ((struct sockaddr_in *)
  40. res->ai_addr)->sin_addr.s_addr;
  41. } else {
  42. sa_in6 = (struct sockaddr_in6 *)&h->ss;
  43. +#ifdef SIN6_LEN
  44. sa_in6->sin6_len = sizeof(struct sockaddr_in6);
  45. +#endif
  46. memcpy(&sa_in6->sin6_addr, &((struct sockaddr_in6 *)
  47. res->ai_addr)->sin6_addr, sizeof(struct in6_addr));
  48. }
  49. diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
  50. index 41fa9ba1fc..3dbd0b0c8e 100644
  51. --- a/src/usr.sbin/ntpd/parse.y
  52. +++ b/src/usr.sbin/ntpd/parse.y
  53. @@ -138,15 +138,17 @@ main : LISTEN ON address listen_opts {
  54. memset(&sin4, 0, sizeof(sin4));
  55. sin4.sin_family = AF_INET;
  56. - sin4.sin_len = sizeof(struct sockaddr_in);
  57. memset(&sin6, 0, sizeof(sin6));
  58. sin6.sin6_family = AF_INET6;
  59. +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  60. + sin4.sin_len = sizeof(struct sockaddr_in);
  61. sin6.sin6_len = sizeof(struct sockaddr_in6);
  62. +#endif
  63. if (inet_pton(AF_INET, $3, &sin4.sin_addr) == 1)
  64. - memcpy(&query_addr4, &sin4, sin4.sin_len);
  65. + memcpy(&query_addr4, &sin4, sizeof(struct sockaddr_in));
  66. else if (inet_pton(AF_INET6, $3, &sin6.sin6_addr) == 1)
  67. - memcpy(&query_addr6, &sin6, sin6.sin6_len);
  68. + memcpy(&query_addr6, &sin6, sizeof(struct sockaddr_in6));
  69. else {
  70. yyerror("invalid IPv4 or IPv6 address: %s\n",
  71. $3);
  72. --
  73. 2.14.0