glib-strlcpy.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Index: netcat-openbsd-1.89/netcat.c
  2. ===================================================================
  3. --- netcat-openbsd-1.89.orig/netcat.c 2007-02-20 09:11:17.000000000 -0500
  4. +++ netcat-openbsd-1.89/netcat.c 2008-01-21 18:48:23.000000000 -0500
  5. @@ -55,6 +55,8 @@
  6. #include <limits.h>
  7. #include "atomicio.h"
  8. +#include <glib.h>
  9. +
  10. #ifndef SUN_LEN
  11. #define SUN_LEN(su) \
  12. (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
  13. @@ -414,7 +416,7 @@
  14. memset(&sun, 0, sizeof(struct sockaddr_un));
  15. sun.sun_family = AF_UNIX;
  16. - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
  17. + if (g_strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
  18. sizeof(sun.sun_path)) {
  19. close(s);
  20. errno = ENAMETOOLONG;
  21. @@ -445,7 +447,7 @@
  22. memset(&sun, 0, sizeof(struct sockaddr_un));
  23. sun.sun_family = AF_UNIX;
  24. - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
  25. + if (g_strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
  26. sizeof(sun.sun_path)) {
  27. close(s);
  28. errno = ENAMETOOLONG;
  29. @@ -549,11 +551,11 @@
  30. if ((s = socket(res0->ai_family, res0->ai_socktype,
  31. res0->ai_protocol)) < 0)
  32. continue;
  33. -
  34. + #ifdef SO_REUSEPORT
  35. ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
  36. if (ret == -1)
  37. err(1, NULL);
  38. -
  39. + #endif
  40. set_common_sockopts(s);
  41. if (bind(s, (struct sockaddr *)res0->ai_addr,
  42. @@ -719,7 +721,8 @@
  43. char *c;
  44. for (x = 0; x <= (hi - lo); x++) {
  45. - y = (arc4random() & 0xFFFF) % (hi - lo);
  46. + /* use random instead of arc4random */
  47. + y = (random() & 0xFFFF) % (hi - lo);
  48. c = portlist[x];
  49. portlist[x] = portlist[y];
  50. portlist[y] = c;
  51. @@ -761,21 +764,25 @@
  52. {
  53. int x = 1;
  54. +#ifdef TCP_MD5SIG
  55. if (Sflag) {
  56. if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
  57. &x, sizeof(x)) == -1)
  58. err(1, NULL);
  59. }
  60. +#endif
  61. if (Dflag) {
  62. if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
  63. &x, sizeof(x)) == -1)
  64. err(1, NULL);
  65. }
  66. +#ifdef SO_JUMBO
  67. if (jflag) {
  68. if (setsockopt(s, SOL_SOCKET, SO_JUMBO,
  69. &x, sizeof(x)) == -1)
  70. err(1, NULL);
  71. }
  72. +#endif
  73. if (Tflag != -1) {
  74. if (setsockopt(s, IPPROTO_IP, IP_TOS,
  75. &Tflag, sizeof(Tflag)) == -1)
  76. @@ -816,9 +823,11 @@
  77. \t-n Suppress name/port resolutions\n\
  78. \t-P proxyuser\tUsername for proxy authentication\n\
  79. \t-p port\t Specify local port for remote connects\n\
  80. - \t-r Randomize remote ports\n\
  81. - \t-S Enable the TCP MD5 signature option\n\
  82. - \t-s addr\t Local source address\n\
  83. + \t-r Randomize remote ports\n "
  84. +#ifdef TCP_MD5SIG
  85. +" \t-S Enable the TCP MD5 signature option\n"
  86. +#endif
  87. +" \t-s addr\t Local source address\n\
  88. \t-T ToS\t Set IP Type of Service\n\
  89. \t-t Answer TELNET negotiation\n\
  90. \t-U Use UNIX domain socket\n\