mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +00:00
prog/dump/*.c, prog/detect/*.c: Handle possible error in fgets().
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4080 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -177,9 +177,14 @@ found:
|
||||
int i2cbus;
|
||||
enum adt type;
|
||||
char x[120];
|
||||
char *px;
|
||||
|
||||
fgets(x, 120, f);
|
||||
px = fgets(x, 120, f);
|
||||
fclose(f);
|
||||
if (!px) {
|
||||
fprintf(stderr, "%s: read error\n", n);
|
||||
continue;
|
||||
}
|
||||
if((border = index(x, '\n')) != NULL)
|
||||
*border = 0;
|
||||
if(count++ == 0 && !procfmt)
|
||||
|
@@ -281,8 +281,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@@ -156,8 +156,8 @@ int confirm(const char *filename, int address, int size, int daddress, int pec)
|
||||
|
||||
fprintf(stderr, "Continue? [%s] ", dont ? "y/N" : "Y/n");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if ((s[0] != '\n' || dont) && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| ((s[0] != '\n' || dont) && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -192,8 +192,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [%s] ", dont ? "y/N" : "Y/n");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if ((s[0] != '\n' || dont) && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| ((s[0] != '\n' || dont) && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -228,8 +228,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@@ -248,8 +248,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@@ -179,8 +179,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -234,8 +234,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
if (!fgets(s, 2, stdin)
|
||||
|| (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y')) {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user