shithub: riscv

Download patch

ref: d7f4ef7bbced0b912164f110fc7337d3b77fae9b
parent: 8aee1c506021ed4352e475b2af4775ec8e8dc805
author: cinap_lenrek <[email protected]>
date: Mon Aug 3 10:45:23 EDT 2015

libauthsrv: readnvram() use vlong for nvroff, parse $nvlen/$nvoff with strtol() instead of atoi()

--- a/sys/src/libauthsrv/readnvram.c
+++ b/sys/src/libauthsrv/readnvram.c
@@ -127,8 +127,8 @@
 
 typedef struct {
 	int	fd;
-	int	safeoff;
 	int	safelen;
+	vlong	safeoff;
 } Nvrwhere;
 
 static char *nvrfile = nil, *cputype = nil;
@@ -138,7 +138,8 @@
 findnvram(Nvrwhere *locp)
 {
 	char *nvrlen, *nvroff, *v[2];
-	int fd, i, safeoff, safelen;
+	int fd, i, safelen;
+	vlong safeoff;
 
 	if (nvrfile == nil)
 		nvrfile = getenv("nvram");
@@ -170,13 +171,13 @@
 			safeoff = 0;
 		nvrlen = getenv("nvrlen");
 		if(nvrlen != nil)
-			safelen = atoi(nvrlen);
+			safelen = strtol(nvrlen, 0, 0);
 		nvroff = getenv("nvroff");
 		if(nvroff != nil)
 			if(strcmp(nvroff, "dos") == 0)
 				safeoff = -1;
 			else
-				safeoff = atoi(nvroff);
+				safeoff = strtoll(nvroff, 0, 0);
 		if(safeoff < 0 && fd >= 0){
 			safelen = 512;
 			safeoff = finddosfile(fd, i == 2? v[1]: "plan9.nvr");
@@ -253,7 +254,7 @@
 				if(loc.fd < 0)
 					fprint(2, "can't open %s: %r\n", nvrfile);
 				else if (seek(loc.fd, loc.safeoff, 0) < 0)
-					fprint(2, "can't seek %s to %d: %r\n",
+					fprint(2, "can't seek %s to %lld: %r\n",
 						nvrfile, loc.safeoff);
 				else
 					fprint(2, "can't read %d bytes from %s: %r\n",