Explorar o código

applied Jukka's patch preventing some cornercases and making the EOF error message correct

arg@mig29 %!s(int64=19) %!d(string=hai) anos
pai
achega
35e96b8deb
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      main.c

+ 2 - 1
main.c

@@ -277,10 +277,11 @@ main(int argc, char *argv[]) {
 			switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
 			case -1:
 				strncpy(stext, strerror(errno), sizeof stext - 1);
+				stext[sizeof stext - 1] = '\0';
 				readin = False;
 				break;
 			case 0:
-				strncpy(stext, "EOF", sizeof stext);
+				strncpy(stext, "EOF", 4);
 				readin = False;
 				break;
 			default: