commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_8-141-geb560b5


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_8-141-geb560b5
Date: Fri, 28 Oct 2011 08:56:38 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  eb560b5bcb985f24bb99de4e3fa6fd618cff2eaf (commit)
       via  e19d48d6a01fd8ee57a9aefbbfacbd90813fdeef (commit)
      from  290a699d8c3780ca9a9907eeca3036c87cde282c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=eb560b5bcb985f24bb99de4e3fa6fd618cff2eaf


commit eb560b5bcb985f24bb99de4e3fa6fd618cff2eaf
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Oct 27 23:59:13 2011 +0200

    tftpd: Use sendto() instead of send().

diff --git a/ChangeLog b/ChangeLog
index 9132370..ea339fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-10-27  Mats Erik Andersson <address@hidden>
 
+       * src/tftpd.c (main) [HAVE_STRUCT_SOCKADDR_SA_LEN]: Assign
+       value to `sin.ss_len'.
+       (main): Do not use connect() on the socket.
+       (send_file, recvfile, nak): Replace send() by sendto().
+
+2011-10-27  Mats Erik Andersson <address@hidden>
+
        * configure.ac (HAVE_STRUCT_TFTPHDR_TH_U): Detect whether
        `struct tftphdr' contains a member `th_u'.
        * src/tftp.c (makerequest, tpacket) [HAVE_STRUCT_TFTPHDR_TH_U]:
diff --git a/src/tftpd.c b/src/tftpd.c
index 2777919..44cb333 100644
--- a/src/tftpd.c
+++ b/src/tftpd.c
@@ -288,16 +288,15 @@ main (int argc, char *argv[])
     }
   memset (&sin, 0, sizeof (sin));
   sin.ss_family = from.ss_family;
+#if HAVE_STRUCT_SOCKADDR_SA_LEN
+  sin.ss_len = from.ss_len;
+#endif
   if (bind (peer, (struct sockaddr *) &sin, fromlen) < 0)
     {
       syslog (LOG_ERR, "bind: %m\n");
       exit (EXIT_FAILURE);
     }
-  if (connect (peer, (struct sockaddr *) &from, fromlen) < 0)
-    {
-      syslog (LOG_ERR, "connect: %m\n");
-      exit (EXIT_FAILURE);
-    }
+
   tp = (struct tftphdr *) buf;
   tp->th_opcode = ntohs (tp->th_opcode);
   if (tp->th_opcode == RRQ || tp->th_opcode == WRQ)
@@ -564,7 +563,8 @@ send_file (struct formats *pf)
       sigsetjmp (timeoutbuf, SIGALRM);
 
     send_data:
-      if (send (peer, (const char *) dp, size + 4, 0) != size + 4)
+      if (sendto (peer, (const char *) dp, size + 4, 0,
+                (struct sockaddr *) &from, fromlen) != size + 4)
        {
          syslog (LOG_ERR, "tftpd: write: %m\n");
          goto abort;
@@ -634,7 +634,7 @@ recvfile (struct formats *pf)
       block++;
       sigsetjmp (timeoutbuf, SIGALRM);
     send_ack:
-      if (send (peer, ackbuf, 4, 0) != 4)
+      if (sendto (peer, ackbuf, 4, 0, (struct sockaddr *) &from, fromlen) != 4)
        {
          syslog (LOG_ERR, "tftpd: write: %m\n");
          goto abort;
@@ -683,7 +683,7 @@ recvfile (struct formats *pf)
 
   ap->th_opcode = htons ((u_short) ACK);       /* send the "final" ack */
   ap->th_block = htons ((u_short) (block));
-  send (peer, ackbuf, 4, 0);
+  sendto (peer, ackbuf, 4, 0, (struct sockaddr *) &from, fromlen);
 
   signal (SIGALRM, justquit);  /* just quit on timeout */
   alarm (rexmtval);
@@ -693,7 +693,7 @@ recvfile (struct formats *pf)
       dp->th_opcode == DATA && /* and got a data block */
       block == dp->th_block)
     {                          /* then my last ack was lost */
-      send (peer, ackbuf, 4, 0);       /* resend final ack */
+      sendto (peer, ackbuf, 4, 0, (struct sockaddr *) &from, fromlen); /* 
resend final ack */
     }
 abort:
   return;
@@ -758,7 +758,7 @@ nak (int error)
   length = strlen (pe->e_msg);
   tp->th_msg[length] = '\0';
   length += 5;
-  if (send (peer, buf, length, 0) != length)
+  if (sendto (peer, buf, length, 0, (struct sockaddr *) &from, fromlen) != 
length)
     syslog (LOG_ERR, "nak: %m\n");
 }
 

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=e19d48d6a01fd8ee57a9aefbbfacbd90813fdeef


commit e19d48d6a01fd8ee57a9aefbbfacbd90813fdeef
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Oct 27 16:18:04 2011 +0200

    tftp,tftpd: `struct tftphdr' depends on OS.

diff --git a/ChangeLog b/ChangeLog
index fa7e87b..9132370 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-10-27  Mats Erik Andersson <address@hidden>
+
+       * configure.ac (HAVE_STRUCT_TFTPHDR_TH_U): Detect whether
+       `struct tftphdr' contains a member `th_u'.
+       * src/tftp.c (makerequest, tpacket) [HAVE_STRUCT_TFTPHDR_TH_U]:
+       Use pointer variable `tp->th_stuff', or generate a correct pointer.
+       * src/tftpd.c (tftp) [HAVE_STRUCT_TFTPHDR_TH_U]: Likewise.
+
 2011-10-27  Alfred M. Szmidt  <address@hidden>
 
        * telnetd/Makefile.am (INCLUDES): Add -I$(top_srcdir) to list.
diff --git a/configure.ac b/configure.ac
index 13d0aba..06c6a39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -548,6 +548,14 @@ IU_CHECK_MEMBERS([struct hostent.h_addr_list], , , 
[#include <netdb.h>])
 
 IU_CHECK_MEMBERS([struct stat.st_blksize])
 
+dnl OpenSolaris does not use a union for `struct tftphdr.th_u'.
+dnl As a consequence `struct tftphdr.th_stuff' is a macro
+dnl resolving to a `ushort_t'. BSD and Linux produce `char *'.
+IU_CHECK_MEMBERS([struct tftphdr.th_u], , ,
+                [#include <sys/types.h>
+                 #include <sys/socket.h>
+                 #include <arpa/tftp.h>])
+
 ### Checks for compiler characteristics.
 AM_C_PROTOTYPES dnl FIXME: Does inetutils even compile on pre-ANSI compilers?
 AC_C_CONST
diff --git a/src/tftp.c b/src/tftp.c
index 9330cbd..46eb7eb 100644
--- a/src/tftp.c
+++ b/src/tftp.c
@@ -1071,7 +1071,11 @@ makerequest (int request, const char *name, struct 
tftphdr *tp,
   register char *cp;
 
   tp->th_opcode = htons ((u_short) request);
+#if HAVE_STRUCT_TFTPHDR_TH_U
   cp = tp->th_stuff;
+#else
+  cp = (char *) &(tp->th_stuff);
+#endif
   strcpy (cp, name);
   cp += strlen (name);
   *cp++ = '\0';
@@ -1148,7 +1152,11 @@ tpacket (const char *s, struct tftphdr *tp, int n)
     case RRQ:
     case WRQ:
       n -= 2;
+#if HAVE_STRUCT_TFTPHDR_TH_U
       file = cp = tp->th_stuff;
+#else
+      file = cp = (char *) &(tp->th_stuff);
+#endif
       cp = strchr (cp, '\0');
       printf ("<file=%s, mode=%s>\n", file, cp + 1);
       break;
diff --git a/src/tftpd.c b/src/tftpd.c
index ea4122e..2777919 100644
--- a/src/tftpd.c
+++ b/src/tftpd.c
@@ -335,7 +335,11 @@ tftp (struct tftphdr *tp, int size)
   register struct formats *pf;
   char *filename, *mode;
 
+#if HAVE_STRUCT_TFTPHDR_TH_U
   filename = cp = tp->th_stuff;
+#else
+  filename = cp = (char *) &(tp->th_stuff);
+#endif
 again:
   while (cp < buf + size)
     {

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog    |   15 +++++++++++++++
 configure.ac |    8 ++++++++
 src/tftp.c   |    8 ++++++++
 src/tftpd.c  |   24 ++++++++++++++----------
 4 files changed, 45 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]