Commits

Anonymous committed 4beb17e

don't allow buffer overflow, and add ^V

Comments (0)

Files changed (1)

 						len -= cur - i;
 						cur = i;
 						break;
+					case CTRL('v') : read(STDIN, &c, 1); // fall through
 					default :
+						if (len == sizeof(usrbuf)) {
+							fputc('\n', stderr);
+							warnx("full input buffer");
+							break;
+						}
 						if (cur != len)
 							memmove(usrbuf + cur + 1, usrbuf + cur, len - cur);
 						usrbuf[cur++] = c;