Author: pepeto
Date: Fri Oct 24 18:20:16 2014
New Revision: 26842

URL: http://svn.gna.org/viewcvs/freeciv?rev=26842&view=rev
Log:
When configured with HAVE_GETLINE and !HAVE_LIBREADLINE, make user empty line
not ignoring the standard input stream.

Reported by Marko Lindqvist <cazfi>

See gna bug #18254

Modified:
    branches/S2_5/server/sernet.c

Modified: branches/S2_5/server/sernet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/sernet.c?rev=26842&r1=26841&r2=26842&view=diff
==============================================================================
--- branches/S2_5/server/sernet.c       (original)
+++ branches/S2_5/server/sernet.c       Fri Oct 24 18:20:16 2014
@@ -808,12 +808,13 @@
       buffer = malloc(BUF_SIZE + 1);
 
       didget = read(0, buffer, BUF_SIZE);
+      if (didget > 0) {
+        buffer[didget] = '\0';
+      } else {
+        didget = -1; /* error or end-of-file: closing stdin... */
+      }
+#endif /* HAVE_GETLINE */
       if (didget < 0) {
-        didget = 0; /* Avoid buffer underrun below. */
-      }
-      *(buffer+didget)='\0';
-#endif /* HAVE_GETLINE */
-      if (didget <= 0) {
         handle_stdin_close();
       }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to