add code to fuzz terminology (wip)

This commit is contained in:
Boris Faure 2015-09-20 23:26:26 +02:00
parent 88c4ce46b0
commit d11ebd1247
2 changed files with 322 additions and 15 deletions

260
afl/in/colors_fonts Normal file

File diff suppressed because one or more lines are too long

View File

@ -182,13 +182,19 @@ _cb_exe_exit(void *data, int type EINA_UNUSED, void *event)
}
static Eina_Bool
_cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
_cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
{
Termpty *ty = data;
char buf[4097];
Eina_Unicode codepoint[4097];
int len, i, j, k, reads;
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
{
ERR("error while reading from tty slave fd");
return ECORE_CALLBACK_CANCEL;
}
// read up to 64 * 4096 bytes
for (reads = 0; reads < 64; reads++)
{
@ -202,6 +208,11 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
len--;
}
len = read(ty->fd, rbuf, len);
if (len < 0 && errno != EAGAIN)
{
ERR("error while reading from tty slave fd");
break;
}
if (len <= 0) break;
@ -265,6 +276,25 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
_handle_buf(ty, codepoint, j);
}
if (ty->cb.change.func) ty->cb.change.func(ty->cb.change.data);
if (len <= 0)
{
if (42)
{
ty->exit_code = 0;
ty->pid = -1;
if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit);
ty->hand_exe_exit = NULL;
if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
ty->hand_fd = NULL;
ty->fd = -1;
ty->slavefd = -1;
if (ty->cb.exited.func)
ty->cb.exited.func(ty->cb.exited.data);
}
return ECORE_CALLBACK_CANCEL;
}
return EINA_TRUE;
}
@ -320,6 +350,19 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
ty->circular_offset = 0;
/* TODO: boris */
if (42)
{
ty->fd = STDIN_FILENO;
ty->hand_fd = ecore_main_fd_handler_add(ty->fd,
ECORE_FD_READ | ECORE_FD_ERROR,
_cb_fd_read, ty,
NULL, NULL);
_pty_size(ty);
termpty_save_register(ty);
return ty;
}
needs_shell = ((!cmd) ||
(strpbrk(cmd, " |&;<>()$`\\\"'*?#") != NULL));
DBG("cmd='%s' needs_shell=%u", cmd ? cmd : "", needs_shell);
@ -866,10 +909,14 @@ termpty_cellrow_get(Termpty *ty, int y_requested, ssize_t *wret)
void
termpty_write(Termpty *ty, const char *input, int len)
{
if (ty->fd < 0) return;
if (write(ty->fd, input, len) < 0)
int fd = ty->fd;
/* TODO: boris */
fd = STDOUT_FILENO;
if (fd < 0) return;
if (write(fd, input, len) < 0)
ERR(_("Could not write to file descriptor %d: %s"),
ty->fd, strerror(errno));
fd, strerror(errno));
}
struct screen_info