2
0
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:
Jean Delvare
2006-08-01 09:46:50 +00:00
parent dd7848c788
commit 4c211d81d9
7 changed files with 22 additions and 17 deletions

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}