]> granicus.if.org Git - nethack/commitdiff
Macintosh getlin and BUFSZ
authorkmhugo <kmhugo>
Sat, 2 Feb 2002 05:34:17 +0000 (05:34 +0000)
committerkmhugo <kmhugo>
Sat, 2 Feb 2002 05:34:17 +0000 (05:34 +0000)
Ensure getline() returns no more than BUFSZ characters
on the Macintosh port.

sys/mac/macwin.c

index 3e69811273a087c048301e6b0d81f71b8ac7bf34..0cbbdc0a9e9c284c653171e241cedd038c1a828d 100644 (file)
@@ -818,6 +818,10 @@ leave_topl_mode(char *answer) {
        if (!in_topl_mode())
                return;
 
+       /* Cap length of reply */
+       if (ans_len >= BUFSZ)
+               ans_len = BUFSZ-1;
+
        /* remove unprintables from the answer */
        for (ap = *(*top_line)->hText + topl_query_len, bp = answer; ans_len > 0; ans_len--, ap++) {
                if (*ap >= ' ' && *ap < 128) {