Netboot Mailing List (by thread)

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

eliminate trailing NULs




  Hello,

  RFC 2132 says that a NVT string shouldn't contain any trailing NUL
but it also says that any client must delete trailing NULs, if any. So
I wrote a patch for etherboot-4.6.2, to make it more robust. Here it
is:

--- main.c.orig	Thu Jun  8 00:31:53 2000
+++ main.c	Thu Jun  8 00:29:40 2000
@@ -1025,8 +1025,20 @@
 		extdata = extend = endp;
 		if (block == 0 && extpath != NULL) {
 			char fname[64];
-			memcpy(fname, extpath+2, TAG_LEN(extpath));
-			fname[(int)TAG_LEN(extpath)] = '\000';
+			int fnamelen = TAG_LEN(extpath);
+
+			while (*(extpath+2+fnamelen-1) == '\000' && fnamelen > 0)
+				fnamelen--;
+			if (fnamelen + 1 > sizeof (fname)) {
+				printf("Too long filename for Extensions Path.\n");
+				return 0;
+			}
+			else if (fnamelen == 0) {
+				printf("Empty filename for Extensions Path.\n");
+				return 0;
+			}
+			memcpy(fname, extpath+2, fnamelen);
+			fname[fnamelen] = '\000';
 			printf("Loading BOOTP-extension file: %s\n",fname);
 			download(fname,decode_rfc1533);
 		}


Regards,
Okuji
===========================================================================
This Mail was sent to netboot mailing list by:
OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
To get help about this list, send a mail with 'help' as the only string in
it's body to majordomo@baghira.han.de. If you have problems with this list,
send a mail to netboot-owner@baghira.han.de.



For requests or suggestions regarding this mailing list archive please write to netboot@gkminix.han.de.