Backport 10853, 10860/10870, and 10862.
authorRob Landley <rob@landley.net>
Fri, 12 Aug 2005 06:06:54 +0000 (06:06 -0000)
committerRob Landley <rob@landley.net>
Fri, 12 Aug 2005 06:06:54 +0000 (06:06 -0000)
busybox/libbb/copy_file.c
busybox/networking/nc.c
busybox/networking/traceroute.c

index 68a1ded04ae99df2aa7bfc5d0717f0e290e877e3..4b349b7fcf9c4b1f107f4fb773ab2c0b46388e50 100644 (file)
@@ -197,12 +197,16 @@ int copy_file(const char *source, const char *dest, int flags)
            S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode) ||
            S_ISLNK(source_stat.st_mode)) {
 
-               if (dest_exists &&
-                      ((flags & FILEUTILS_FORCE) == 0 || unlink(dest) < 0)) {
+               if (dest_exists) {
+                       if((flags & FILEUTILS_FORCE) == 0) {
+                               fprintf(stderr, "`%s' exists\n", dest);
+                               return -1;
+                       }
+                       if(unlink(dest) < 0) {
                                bb_perror_msg("unable to remove `%s'", dest);
                                return -1;
-
                        }
+               }
        } else {
                bb_error_msg("internal error: unrecognized file type");
                return -1;
index ab8ec0cd5c456cc47b946cf2ba126d4c78ac48d3..6ce85fecfa243943ced6ffd87e9ad277edde3a66 100644 (file)
@@ -161,8 +161,11 @@ int nc_main(int argc, char **argv)
                                                exit(0);
                                        ofd = STDOUT_FILENO;
                                } else {
-                                       if (nread == 0)
-                                               shutdown(sfd, 1);
+                                       if (nread <= 0) {
+                                               shutdown(sfd, 1 /* send */ );
+                                               close(STDIN_FILENO);
+                                               FD_CLR(STDIN_FILENO, &readfds);
+                                       }
                                        ofd = sfd;
                                }
 
index 44ffdf07e34704ad3ee50abc69f29baa5f6b52fb..cf90ec088fe2e3e14580f533a0d6e16696b097b3 100644 (file)
@@ -101,7 +101,8 @@ struct opacket {
 
 #include "busybox.h"
 
-static u_char  packet[512];            /* last inbound (icmp) packet */
+                                       /* last inbound (icmp) packet */
+static u_char  packet[512] __attribute__ ((aligned));
 static struct opacket  *outpacket;     /* last output (udp) packet */
 
 static int s;                          /* receive (icmp) socket file descriptor */