In Bug 78, shortkey points out:
[oweals/busybox.git] / networking / tftp.c
index bd973d79ae4b4bf028a3754ba21864d07db5c00b..3c947318bc89f3def3e51fd7ab706eaf7a87802f 100644 (file)
@@ -267,7 +267,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
                        block_nr++;
 
                        if (cmd_put && (opcode == TFTP_DATA)) {
-                               len = read(localfd, cp, tftp_bufsize - 4);
+                               len = bb_full_read(localfd, cp, tftp_bufsize - 4);
 
                                if (len < 0) {
                                        bb_perror_msg("read");
@@ -444,7 +444,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
 
                        if (tmp == block_nr) {
                        
-                               len = write(localfd, &buf[4], len - 4);
+                               len = bb_full_write(localfd, &buf[4], len - 4);
 
                                if (len < 0) {
                                        bb_perror_msg("write");
@@ -485,8 +485,8 @@ static inline int tftp(const int cmd, const struct hostent *host,
 int tftp_main(int argc, char **argv)
 {
        struct hostent *host = NULL;
-       char *localfile = NULL;
-       char *remotefile = NULL;
+       const char *localfile = NULL;
+       const char *remotefile = NULL;
        int port;
        int cmd = 0;
        int fd = -1;
@@ -538,10 +538,10 @@ int tftp_main(int argc, char **argv)
                        break;
 #endif
                case 'l':
-                       localfile = bb_xstrdup(optarg);
+                       localfile = optarg;
                        break;
                case 'r':
-                       remotefile = bb_xstrdup(optarg);
+                       remotefile = optarg;
                        break;
                }
        }
@@ -576,7 +576,7 @@ int tftp_main(int argc, char **argv)
        result = tftp(cmd, host, remotefile, fd, port, blocksize);
 
 #ifdef CONFIG_FEATURE_CLEAN_UP
-       if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
+       if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) {
            close(fd);
        }
 #endif