about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2012-03-01 11:26:45 -0600
committerMarco Peereboom <marco@conformal.com>2012-03-01 11:26:45 -0600
commit250e3dccbb7f00764274cccbc467d0ce50d8195f (patch)
treeef133a47756a633f9a7bfd042b8b9140af18aa55
parentbe09e30a6cb63efc36cecb4f1d2d0a2e438354ed (diff)
downloadxombrero-250e3dccbb7f00764274cccbc467d0ce50d8195f.tar.gz
make sure we eat \n during sod fgets
-rw-r--r--xxxterm.c7
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();
 		}