libauthsrv: readnvram() use vlong for nvroff, parse $nvlen/$nvoff with strtol() instead of atoi()
This commit is contained in:
parent
8aee1c5060
commit
d7f4ef7bbc
1 changed files with 6 additions and 5 deletions
|
@ -127,8 +127,8 @@ readcons(char *prompt, char *def, int raw, char *buf, int nbuf)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
int safeoff;
|
|
||||||
int safelen;
|
int safelen;
|
||||||
|
vlong safeoff;
|
||||||
} Nvrwhere;
|
} Nvrwhere;
|
||||||
|
|
||||||
static char *nvrfile = nil, *cputype = nil;
|
static char *nvrfile = nil, *cputype = nil;
|
||||||
|
@ -138,7 +138,8 @@ static void
|
||||||
findnvram(Nvrwhere *locp)
|
findnvram(Nvrwhere *locp)
|
||||||
{
|
{
|
||||||
char *nvrlen, *nvroff, *v[2];
|
char *nvrlen, *nvroff, *v[2];
|
||||||
int fd, i, safeoff, safelen;
|
int fd, i, safelen;
|
||||||
|
vlong safeoff;
|
||||||
|
|
||||||
if (nvrfile == nil)
|
if (nvrfile == nil)
|
||||||
nvrfile = getenv("nvram");
|
nvrfile = getenv("nvram");
|
||||||
|
@ -170,13 +171,13 @@ findnvram(Nvrwhere *locp)
|
||||||
safeoff = 0;
|
safeoff = 0;
|
||||||
nvrlen = getenv("nvrlen");
|
nvrlen = getenv("nvrlen");
|
||||||
if(nvrlen != nil)
|
if(nvrlen != nil)
|
||||||
safelen = atoi(nvrlen);
|
safelen = strtol(nvrlen, 0, 0);
|
||||||
nvroff = getenv("nvroff");
|
nvroff = getenv("nvroff");
|
||||||
if(nvroff != nil)
|
if(nvroff != nil)
|
||||||
if(strcmp(nvroff, "dos") == 0)
|
if(strcmp(nvroff, "dos") == 0)
|
||||||
safeoff = -1;
|
safeoff = -1;
|
||||||
else
|
else
|
||||||
safeoff = atoi(nvroff);
|
safeoff = strtoll(nvroff, 0, 0);
|
||||||
if(safeoff < 0 && fd >= 0){
|
if(safeoff < 0 && fd >= 0){
|
||||||
safelen = 512;
|
safelen = 512;
|
||||||
safeoff = finddosfile(fd, i == 2? v[1]: "plan9.nvr");
|
safeoff = finddosfile(fd, i == 2? v[1]: "plan9.nvr");
|
||||||
|
@ -253,7 +254,7 @@ readnvram(Nvrsafe *safep, int flag)
|
||||||
if(loc.fd < 0)
|
if(loc.fd < 0)
|
||||||
fprint(2, "can't open %s: %r\n", nvrfile);
|
fprint(2, "can't open %s: %r\n", nvrfile);
|
||||||
else if (seek(loc.fd, loc.safeoff, 0) < 0)
|
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);
|
nvrfile, loc.safeoff);
|
||||||
else
|
else
|
||||||
fprint(2, "can't read %d bytes from %s: %r\n",
|
fprint(2, "can't read %d bytes from %s: %r\n",
|
||||||
|
|
Loading…
Reference in a new issue