Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 29 Mar 2002 12:13:22 -0500 (EST) From: David E Euresti To: Subject: sendto bug Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hello, I believe the implementation of sendto in cygwin.dll has a bug. The following code works on linux but not on cygwin. I believe the reason is that cygwin checks whether the to field is null however it is absolutely permissible for the to field to be null, as seen in the following line at net.cc if ((len && __check_invalid_read_ptr_errno (buf, (unsigned) len)) || __check_null_invalid_struct_errno (to, tolen) || !h) I think that if we replace this with if ((len && __check_invalid_read_ptr_errno (buf, (unsigned) len)) || to && __check_null_invalid_struct_errno (to, tolen) || !h) and then make sure the get_inet_addr doesn't get called it would work correctly, as both WSAsendto and winsock 1 sendto accept null to's. I would do this myself but I haven't been successful yet at building cygwin, and I would like this bug to be corrected in the distribution. Thanks, David Euresti -- Begin test code -- #include #include #include void fatal(char *msg) { printf("%s: %s\n", msg,strerror(errno)); exit(1); } int main() { int fds[2]; char buf[] = "Hello"; char buf2[256]; if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds)<0) fatal("socketpair"); if (sendto(fds[0],buf, sizeof(buf), 0, NULL, 0) < 0) fatal("sendto"); if (recvfrom(fds[1], buf2, sizeof(buf2), 0, NULL, 0) < 0) fatal("recvfrom"); printf("Message is %s\n", buf2); } -- End test code -- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/