rpms/tftp/F-13 tftp-0.49-cmd_arg.patch,NONE,1.1 tftp.spec,1.51,1.52

Jiri Skala jskala at fedoraproject.org
Fri May 28 08:24:21 UTC 2010


Author: jskala

Update of /cvs/extras/rpms/tftp/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv8537

Modified Files:
	tftp.spec 
Added Files:
	tftp-0.49-cmd_arg.patch 
Log Message:
* Fri May 28 2010 Jiri Skala <jskala at redhat.com> - 0.49-6
- patched handling arguments of commands (put)


tftp-0.49-cmd_arg.patch:
 config.h       |    1 +
 configure.in   |    1 +
 lib/xrealloc.c |   20 ++++++++++++++++++++
 tftp/main.c    |   48 ++++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 64 insertions(+), 6 deletions(-)

--- NEW FILE tftp-0.49-cmd_arg.patch ---
diff -up tftp-hpa-0.49/config.h.cmd_arg tftp-hpa-0.49/config.h
--- tftp-hpa-0.49/config.h.cmd_arg	2010-04-19 15:29:10.567331454 +0200
+++ tftp-hpa-0.49/config.h	2010-04-20 07:33:03.133232772 +0200
@@ -291,6 +291,7 @@ typedef int socklen_t;
 /* Prototypes for libxtra functions */
 
 void *xmalloc(size_t);
+void *xrealloc(void *, size_t);
 char *xstrdup(const char *);
 
 #ifndef HAVE_BSD_SIGNAL
diff -up tftp-hpa-0.49/configure.in.cmd_arg tftp-hpa-0.49/configure.in
--- tftp-hpa-0.49/configure.in.cmd_arg	2008-10-21 00:08:31.000000000 +0200
+++ tftp-hpa-0.49/configure.in	2010-04-19 11:05:12.387340698 +0200
@@ -152,6 +152,7 @@ OBJROOT=`pwd`
 
 XTRA=false
 PA_SEARCH_LIBS_AND_ADD(xmalloc, iberty)
+PA_SEARCH_LIBS_AND_ADD(xrealloc, iberty)
 PA_SEARCH_LIBS_AND_ADD(xstrdup, iberty)
 PA_SEARCH_LIBS_AND_ADD(bsd_signal, bsd, bsdsignal)
 PA_SEARCH_LIBS_AND_ADD(getopt_long, getopt, getopt_long)
diff -up tftp-hpa-0.49/lib/xrealloc.c.cmd_arg tftp-hpa-0.49/lib/xrealloc.c
--- tftp-hpa-0.49/lib/xrealloc.c.cmd_arg	2010-04-19 11:05:12.387340698 +0200
+++ tftp-hpa-0.49/lib/xrealloc.c	2010-04-19 11:05:12.387340698 +0200
@@ -0,0 +1,20 @@
+/*
+ * xrealloc.c
+ *
+ * Simple error-checking version of realloc()
+ *
+ */
+
+#include "config.h"
+
+void *xrealloc(void *ptr, size_t size)
+{
+    void *p = realloc(ptr, size);
+
+    if (!p) {
+        fprintf(stderr, "Out of memory!\n");
+        exit(128);
+    }
+
+    return p;
+}
diff -up tftp-hpa-0.49/tftp/main.c.cmd_arg tftp-hpa-0.49/tftp/main.c
--- tftp-hpa-0.49/tftp/main.c.cmd_arg	2008-10-21 00:08:31.000000000 +0200
+++ tftp-hpa-0.49/tftp/main.c	2010-04-19 11:05:12.389329337 +0200
@@ -89,11 +89,14 @@ int connected;
 const struct modes *mode;
 #ifdef WITH_READLINE
 char *line = NULL;
+char *remote_pth = NULL;
 #else
 char line[LBUFLEN];
+char remote_pth[LBUFLEN];
 #endif
 int margc;
-char *margv[20];
+char **margv;
+int sizeof_margv=0;
 const char *prompt = "tftp> ";
 sigjmp_buf toplevel;
 void intr(int);
@@ -379,6 +382,10 @@ static void getmoreargs(const char *part
         free(line);
         line = NULL;
     }
+    if (remote_pth) {
+        free(remote_pth);
+        remote_pth = NULL;
+    }
     line = xmalloc(len + elen + 1);
     strcpy(line, partial);
     strcpy(line + len, eline);
@@ -535,6 +542,7 @@ void put(int argc, char *argv[])
     int fd;
     int n, err;
     char *cp, *targ;
+    long dirlen, namelen, lastlen=0;
 
     if (argc < 2) {
         getmoreargs("send ", "(file) ");
@@ -588,9 +596,22 @@ void put(int argc, char *argv[])
     }
     /* this assumes the target is a directory */
     /* on a remote unix system.  hmmmm.  */
-    cp = strchr(targ, '\0');
-    *cp++ = '/';
+    dirlen = strlen(targ)+1;
+#ifdef WITH_READLINE
+    remote_pth = xmalloc(dirlen+1);
+#endif
+    strcpy(remote_pth, targ);
+    remote_pth[dirlen-1] = '/';
+    cp = remote_pth + dirlen;
     for (n = 1; n < argc - 1; n++) {
+#ifdef WITH_READLINE
+        namelen = strlen(tail(argv[n])) + 1;
+        if (namelen > lastlen) {
+            remote_pth = xrealloc(remote_pth, dirlen + namelen + 1);
+            cp = remote_pth + dirlen;
+            lastlen = namelen;
+        }
+#endif
         strcpy(cp, tail(argv[n]));
         fd = open(argv[n], O_RDONLY | mode->m_openflags);
         if (fd < 0) {
@@ -600,9 +621,9 @@ void put(int argc, char *argv[])
         }
         if (verbose)
             printf("putting %s to %s:%s [%s]\n",
-                   argv[n], hostname, targ, mode->m_mode);
+                   argv[n], hostname, remote_pth, mode->m_mode);
         sa_set_port(&peeraddr, port);
-        tftp_sendfile(fd, targ, mode->m_mode);
+        tftp_sendfile(fd, remote_pth, mode->m_mode);
     }
 }
 
@@ -801,6 +822,10 @@ static void command(void)
             free(line);
             line = NULL;
         }
+        if (remote_pth) {
+            free(remote_pth);
+            remote_pth = NULL;
+        }
         line = readline(prompt);
         if (!line)
             exit(0);            /* EOF */
@@ -872,7 +897,13 @@ struct cmd *getcmd(char *name)
 static void makeargv(void)
 {
     char *cp;
-    char **argp = margv;
+    char **argp;
+
+    if (!sizeof_margv) {
+        sizeof_margv = 20;
+        margv = xmalloc(sizeof_margv * sizeof(char *));
+    }
+    argp = margv;
 
     margc = 0;
     for (cp = line; *cp;) {
@@ -882,6 +913,11 @@ static void makeargv(void)
             break;
         *argp++ = cp;
         margc += 1;
+        if (margc == sizeof_margv) {
+            sizeof_margv += 20;
+            margv = xrealloc(margv, sizeof_margv * sizeof(char *));
+            argp = margv + margc;
+        }
         while (*cp != '\0' && !isspace(*cp))
             cp++;
         if (*cp == '\0')


Index: tftp.spec
===================================================================
RCS file: /cvs/extras/rpms/tftp/F-13/tftp.spec,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -p -r1.51 -r1.52
--- tftp.spec	5 Aug 2009 14:22:02 -0000	1.51
+++ tftp.spec	28 May 2010 08:24:21 -0000	1.52
@@ -1,7 +1,7 @@
 Summary: The client for the Trivial File Transfer Protocol (TFTP)
 Name: tftp
 Version: 0.49
-Release: 5%{?dist}
+Release: 6%{?dist}
 License: BSD
 Group: Applications/Internet
 Source0: http://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.bz2
@@ -12,6 +12,7 @@ Patch2: tftp-hpa-0.39-tzfix.patch
 Patch3: tftp-0.42-tftpboot.patch
 Patch4: tftp-0.49-chk_retcodes.patch
 Patch5: tftp-hpa-0.49-fortify-strcpy-crash.patch
+Patch6: tftp-0.49-cmd_arg.patch
 
 BuildRequires: tcp_wrappers-devel readline-devel
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -45,6 +46,7 @@ enabled unless it is expressly needed.  
 %patch3 -p1 -b .tftpboot
 %patch4 -p1 -b .chk_retcodes
 %patch5 -p1 -b .fortify-strcpy-crash
+%patch6 -p1 -b .cmd_arg
 
 %build
 
@@ -90,6 +92,9 @@ rm -rf ${RPM_BUILD_ROOT}
 %{_mandir}/man8/*
 
 %changelog
+* Fri May 28 2010 Jiri Skala <jskala at redhat.com> - 0.49-6
+- patched handling arguments of commands (put)
+
 * Wed Aug 05 2009 Warren Togami <wtogami at redhat.com> - 0.49-5
 - Bug #515361 tftp FORTIFY_SOURCE strcpy crash 
 



More information about the scm-commits mailing list