Guest User

Untitled

a guest
Jun 22nd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. Index: sendmail.c
  2. ===================================================================
  3. RCS file: /repository/php-src/win32/sendmail.c,v
  4. retrieving revision 1.65.2.2.2.1
  5. diff -u -r1.65.2.2.2.1 sendmail.c
  6. --- sendmail.c 24 Feb 2007 02:17:28 -0000 1.65.2.2.2.1
  7. +++ sendmail.c 27 Jun 2009 11:21:46 -0000
  8. @@ -38,6 +38,10 @@
  9. #include "sendmail.h"
  10. #include "php_ini.h"
  11.  
  12. +#if _MSC_VER < 1500
  13. +#include "inet.h"
  14. +#endif
  15. +
  16. #if HAVE_PCRE || HAVE_BUNDLED_PCRE
  17. #include "ext/pcre/php_pcre.h"
  18. #endif
  19. @@ -765,16 +769,50 @@
  20. static int MailConnect()
  21. {
  22.  
  23. - int res;
  24. + int res, namelen;
  25. short portnum;
  26. + struct hostent *ent;
  27. + IN_ADDR addr;
  28. +#ifdef HAVE_IPV6
  29. + IN6_ADDR addr6;
  30. +#endif
  31.  
  32. /* Create Socket */
  33. - if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
  34. + if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
  35. return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
  36. + }
  37.  
  38. /* Get our own host name */
  39. - if (gethostname(LocalHost, HOST_NAME_LEN))
  40. + if (gethostname(LocalHost, HOST_NAME_LEN)) {
  41. return (FAILED_TO_GET_HOSTNAME);
  42. + }
  43. +
  44. + ent = gethostbyname(LocalHost);
  45. +
  46. + if (!ent) {
  47. + return (FAILED_TO_GET_HOSTNAME);
  48. + }
  49. +
  50. + namelen = strlen(ent->h_name);
  51. +
  52. +#ifdef HAVE_IPV6
  53. + if (inet_pton(AF_INET, ent->h_name, &addr) == 1 || inet_pton(AF_INET6, ent->h_name, &addr6) == 1)
  54. +#else
  55. + if (inet_pton(AF_INET, ent->h_name, &addr) == 1)
  56. +#endif
  57. + {
  58. + if (namelen + 2 >= HOST_NAME_LEN) {
  59. + return (FAILED_TO_GET_HOSTNAME);
  60. + }
  61. + strcpy(LocalHost, "[");
  62. + strcpy(LocalHost + 1, ent->h_name);
  63. + strcpy(LocalHost + namelen + 1, "]");
  64. + } else {
  65. + if (namelen >= HOST_NAME_LEN) {
  66. + return (FAILED_TO_GET_HOSTNAME);
  67. + }
  68. + strcpy(LocalHost, ent->h_name);
  69. + }
  70.  
  71. /* Resolve the servers IP */
  72. /*
  73. @@ -794,8 +832,9 @@
  74. sock_in.sin_port = htons(portnum);
  75. sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
  76.  
  77. - if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
  78. + if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in))) {
  79. return (FAILED_TO_CONNECT);
  80. + }
  81.  
  82. /* receive Server welcome message */
  83. res = Ack(NULL);
Add Comment
Please, Sign In to add comment