diff options
author | Marco Peereboom <marco@conformal.com> | 2012-03-01 11:26:45 -0600 |
---|---|---|
committer | Marco Peereboom <marco@conformal.com> | 2012-03-01 11:26:45 -0600 |
commit | 250e3dccbb7f00764274cccbc467d0ce50d8195f (patch) | |
tree | ef133a47756a633f9a7bfd042b8b9140af18aa55 | |
parent | be09e30a6cb63efc36cecb4f1d2d0a2e438354ed (diff) | |
download | xombrero-250e3dccbb7f00764274cccbc467d0ce50d8195f.tar.gz |
make sure we eat \n during sod fgets
-rw-r--r-- | xxxterm.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/xxxterm.c b/xxxterm.c index 2526ccb..c9923bf 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -7783,11 +7783,16 @@ main(int argc, char **argv) /* welcome user */ welcome(); } else { - if ((f = fopen(file, "r")) == NULL) + if ((f = fopen(file, "r+")) == NULL) err(1, "startofday"); if (fgets(sodversion, sizeof sodversion, f) == NULL) err(1, "fgets"); + sodversion[strcspn(sodversion, "\n")] = '\0'; if (strcmp(version, sodversion)) { + rewind(f); + if (fputs(version, f)) + err(1, "fputs"); + /* upgrade, say something smart */ welcome(); } |