Commit Diff


commit - 30bb27ff665e3352363e8f562c78085888983af4
commit + 643a56d30f3d0d65db39a147a09435999b7160d2
blob - cb7d87f51e53dd89f4da4c2e5bc8bb0eb7c8b379
blob + 208a88ac24abd104329c516b6de60d521864ff5f
--- modules/weather.c
+++ modules/weather.c
@@ -43,7 +43,7 @@ get_weather(int fd)
 void
 read_weather(int fd)
 {
-	ssize_t n = read(fd, weather_string, sizeof(weather_string));
+	ssize_t n = read(fd, weather_string, sizeof(weather_string) - 1);
 	char *lnbrk;
 	char garbage[1024];
 	int flags = fcntl(fd, F_GETFL, 0);
@@ -54,6 +54,7 @@ read_weather(int fd)
 		
 		return;
 	}
+	weather_string[n] = '\0';
 	lnbrk = strchr(weather_string, '\n');
 	if (lnbrk) *lnbrk = '\0';
 	(void)fcntl(fd, F_SETFL, flags | O_NONBLOCK);