mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
fix safe mode triggering when opening unreadable f
This commit is contained in:
parent
497c32b05b
commit
5febd48a3e
1 changed files with 7 additions and 0 deletions
|
@ -566,11 +566,13 @@ int main(int argc, char** argv) {
|
||||||
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
reportError(fmt::sprintf("couldn't open file! (%s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (%s)",strerror(errno)));
|
||||||
|
e.everythingOK();
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (fseek(f,0,SEEK_END)<0) {
|
if (fseek(f,0,SEEK_END)<0) {
|
||||||
reportError(fmt::sprintf("couldn't open file! (couldn't get file size: %s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (couldn't get file size: %s)",strerror(errno)));
|
||||||
|
e.everythingOK();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -578,6 +580,7 @@ int main(int argc, char** argv) {
|
||||||
ssize_t len=ftell(f);
|
ssize_t len=ftell(f);
|
||||||
if (len==(SIZE_MAX>>1)) {
|
if (len==(SIZE_MAX>>1)) {
|
||||||
reportError(fmt::sprintf("couldn't open file! (couldn't get file length: %s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (couldn't get file length: %s)",strerror(errno)));
|
||||||
|
e.everythingOK();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -588,6 +591,7 @@ int main(int argc, char** argv) {
|
||||||
} else {
|
} else {
|
||||||
reportError(fmt::sprintf("couldn't open file! (tell error: %s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (tell error: %s)",strerror(errno)));
|
||||||
}
|
}
|
||||||
|
e.everythingOK();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -595,6 +599,7 @@ int main(int argc, char** argv) {
|
||||||
unsigned char* file=new unsigned char[len];
|
unsigned char* file=new unsigned char[len];
|
||||||
if (fseek(f,0,SEEK_SET)<0) {
|
if (fseek(f,0,SEEK_SET)<0) {
|
||||||
reportError(fmt::sprintf("couldn't open file! (size error: %s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (size error: %s)",strerror(errno)));
|
||||||
|
e.everythingOK();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
delete[] file;
|
delete[] file;
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
|
@ -602,6 +607,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
|
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
|
||||||
reportError(fmt::sprintf("couldn't open file! (read error: %s)",strerror(errno)));
|
reportError(fmt::sprintf("couldn't open file! (read error: %s)",strerror(errno)));
|
||||||
|
e.everythingOK();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
delete[] file;
|
delete[] file;
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
|
@ -610,6 +616,7 @@ int main(int argc, char** argv) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (!e.load(file,(size_t)len)) {
|
if (!e.load(file,(size_t)len)) {
|
||||||
reportError(fmt::sprintf("could not open file! (%s)",e.getLastError()));
|
reportError(fmt::sprintf("could not open file! (%s)",e.getLastError()));
|
||||||
|
e.everythingOK();
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue