]> git.pond.sub.org Git - empserver/commitdiff
Oops when mpr() is misused for printing partial lines
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 8 Jun 2010 04:28:25 +0000 (06:28 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 11 Jul 2010 05:59:43 +0000 (07:59 +0200)
Such misuse creates a bulletin with a partial line.  The read command
normally merges it with the next one, but if the bulletins are more
than five seconds apart (clock jumped somehow), we get a bulletin
header in the middle of a line.

src/lib/subs/pr.c

index 5548c9d8bc5b28cfb7f1f53ea693b71131e98770..e707b1c94dad09a5abbaac5d1d4b98db62bab287 100644 (file)
@@ -500,8 +500,9 @@ pr_beep(void)
 }
 
 /*
 }
 
 /*
- * Print to country CN similar to printf().
- * Use printf-style FORMAT with the optional arguments.
+ * Print complete lines to country CN similar to printf().
+ * Use printf-style FORMAT with the optional arguments.  FORMAT must
+ * end with '\n'.
  * If CN is zero, don't print anything.
  * Else, if CN is the current player and we're not in the update,
  * print just like pr().  Else print into a bulletin.
  * If CN is zero, don't print anything.
  * Else, if CN is the current player and we're not in the update,
  * print just like pr().  Else print into a bulletin.
@@ -514,6 +515,7 @@ mpr(int cn, char *format, ...)
     char buf[4096];
     va_list ap;
 
     char buf[4096];
     va_list ap;
 
+    CANT_HAPPEN(!format[0] || format[strlen(format) - 1] != '\n');
     if (!cn)
        return;
     va_start(ap, format);
     if (!cn)
        return;
     va_start(ap, format);