Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ihnp4!ptsfa!lll-lcc!seismo!husc6!sri-unix!hplabs!sdcrdcf!psivax!csun!sdsu!dlong From: dlong@sdsu.UUCP Newsgroups: comp.os.minix Subject: diff for head.c Message-ID: <2549@sdsu.UUCP> Date: Mon, 2-Mar-87 01:48:33 EST Article-I.D.: sdsu.2549 Posted: Mon Mar 2 01:48:33 1987 Date-Received: Wed, 4-Mar-87 19:18:47 EST Reply-To: dlong@sdsu.UUCP (Dean Long) Distribution: world Organization: University of California, San Diego Lines: 37 Keywords: The following is a diff for commands/head.c to hopefully fix a bug that allows the buffer to overflow at EOF or lines longer than 256 characters. ---------------------------------------------------------------------- 1a2 > /* Minor changes by: Dean Long 2/24/87 */ 5a7 > #define LINE 256 8c10 < char lbuf[256]; --- > char lbuf[LINE]; 58c60,61 < while (n--) do_line(); --- > /* Stop at EOF. -dl 2/24/87 */ > while (n-- && do_line()) continue; 66c69,71 < char c, *cp; --- > int c; > char *cp; > 68c73,76 < while ( (c = getc(stdin)) != '\n') *cp++ = c; --- > /* Stop at EOF or buffer full. -dl 2/24/87 */ > while ((c = getc(stdin)) != '\n' && c != EOF && cp < lbuf + LINE - 2) > *cp++ = (char)c; > if (c == EOF) return 0; 71a80 > return 1; -- Dean Long University of California, San Diego sdcsvax!tiamat!dlong