wok-6.x rev 672

Busybox/tftpd: misc fix for PXE
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 23 21:54:13 2008 +0000 (2008-04-23)
parents c2f0c4bc32ae
children b4eb59c224b0
files busybox/stuff/busybox-1.10.1-tftp.u
line diff
     1.1 --- a/busybox/stuff/busybox-1.10.1-tftp.u	Wed Apr 23 23:50:25 2008 +0200
     1.2 +++ b/busybox/stuff/busybox-1.10.1-tftp.u	Wed Apr 23 21:54:13 2008 +0000
     1.3 @@ -1,5 +1,14 @@
     1.4  --- busybox-1.10.1/networking/tftp.c	
     1.5  +++ busybox-1.10.1/networking/tftp.c	
     1.6 +@@ -39,7 +39,7 @@
     1.7 + #define TFTP_ERROR 5
     1.8 + #define TFTP_OACK  6
     1.9 + 
    1.10 +-/* error codes sent over network (we use only 0, 3 and 8) */
    1.11 ++/* error codes sent over network (we use only 0, 1, 3 and 8) */
    1.12 + /* generic (error message is included in the packet) */
    1.13 + #define ERR_UNSPEC   0
    1.14 + #define ERR_NOFILE   1
    1.15  @@ -121,9 +121,8 @@
    1.16   	return blksize;
    1.17   }
    1.18 @@ -27,6 +36,18 @@
    1.19   		int blksize)
    1.20   {
    1.21   #if !ENABLE_TFTP
    1.22 +@@ -243,9 +242,9 @@
    1.23 + 		if (NOT_LONE_DASH(local_file))
    1.24 + 			local_fd = xopen(local_file, open_mode);
    1.25 + 	} else {
    1.26 +-		local_fd = open_or_warn(local_file, open_mode);
    1.27 ++		local_fd = open(local_file, open_mode);
    1.28 + 		if (local_fd < 0) {
    1.29 +-			/*error_pkt_reason = ERR_NOFILE/ERR_ACCESS?*/
    1.30 ++			error_pkt_reason = ERR_NOFILE;
    1.31 + 			strcpy(error_pkt_str, "can't open file");
    1.32 + 			goto send_err_pkt;
    1.33 + 		}
    1.34  @@ -253,7 +252,7 @@
    1.35   
    1.36   	if (!ENABLE_TFTP || our_lsa) {
    1.37 @@ -44,19 +65,19 @@
    1.38  -		strcpy(cp, "blksize");
    1.39  -		cp += sizeof("blksize");
    1.40  -		cp += snprintf(cp, 6, "%d", blksize) + 1;
    1.41 -+		if (blksize != TFTP_BLKSIZE_DEFAULT) {
    1.42 -+			/* add "blksize", <nul>, blksize, <nul> */
    1.43 -+			strcpy(cp, "blksize");
    1.44 -+			cp += sizeof("blksize");
    1.45 -+			cp += snprintf(cp, 6, "%d", blksize) + 1;
    1.46 -+		}
    1.47  +		if (tsize) {
    1.48  +			struct stat st;
    1.49  +			/* add "tsize", <nul>, size, <nul> */
    1.50  +			strcpy(cp, "tsize");
    1.51  +			cp += sizeof("tsize");
    1.52  +			fstat(local_fd,&st);
    1.53 -+			cp += snprintf(cp, 8, "%u", (int) st.st_size) + 1;
    1.54 ++			cp += snprintf(cp, 10, "%u", (int) st.st_size) + 1;
    1.55 ++		}
    1.56 ++		if (blksize != TFTP_BLKSIZE_DEFAULT) {
    1.57 ++			/* add "blksize", <nul>, blksize, <nul> */
    1.58 ++			strcpy(cp, "blksize");
    1.59 ++			cp += sizeof("blksize");
    1.60 ++			cp += snprintf(cp, 6, "%d", blksize) + 1;
    1.61  +		}
    1.62   #endif
    1.63   		/* First packet is built, so skip packet generation */