diff options
author | Karel Kočí <cynerd@email.cz> | 2019-02-09 15:39:01 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2019-02-09 15:39:01 +0100 |
commit | 5105baa9342399c74dd5feb5697efcf041f8c80c (patch) | |
tree | 8052c578e1cb87818cbb5d91b16e43dc15ca01d0 /surf.c | |
parent | efc49f30352636d72095703058bf4983f012235f (diff) | |
parent | d068a3878b6b9f2841a49cd7948cdf9d62b55585 (diff) | |
download | surf-5105baa9342399c74dd5feb5697efcf041f8c80c.tar.gz surf-5105baa9342399c74dd5feb5697efcf041f8c80c.tar.bz2 surf-5105baa9342399c74dd5feb5697efcf041f8c80c.zip |
Merge branch 'surf-webkit2' into mysurfv2.0.8
Diffstat (limited to 'surf.c')
-rw-r--r-- | surf.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -1209,20 +1209,22 @@ newview(Client *c, WebKitWebView *rv) static gboolean readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused) { - char msg[MSGBUFSZ]; - gsize msgsz; + static char msg[MSGBUFSZ], msgsz; GError *gerr = NULL; - if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != + if (g_io_channel_read_chars(s, msg, sizeof(msg), NULL, &gerr) != G_IO_STATUS_NORMAL) { fprintf(stderr, "surf: error reading pipe: %s\n", gerr->message); g_error_free(gerr); return TRUE; } - msg[msgsz] = '\0'; + if ((msgsz = msg[0]) < 3) { + fprintf(stderr, "surf: message too short: %d\n", msgsz); + return TRUE; + } - switch (msg[1]) { + switch (msg[2]) { case 'i': close(pipein[1]); close(pipeout[0]); @@ -1843,12 +1845,18 @@ zoom(Client *c, const Arg *a) static void msgext(Client *c, char type, const Arg *a) { - char msg[MSGBUFSZ] = { c->pageid, type, a->i, '\0' }; + static char msg[MSGBUFSZ]; + int ret; - if (pipeout[1]) { - if (write(pipeout[1], msg, sizeof(msg)) < 0) - fprintf(stderr, "surf: error sending: %s\n", msg); + if ((ret = snprintf(msg, sizeof(msg), "%c%c%c%c", + 4, c->pageid, type, a->i)) + >= sizeof(msg)) { + fprintf(stderr, "surf: message too long: %d\n", ret); + return; } + + if (pipeout[1] && write(pipeout[1], msg, sizeof(msg)) < 0) + fprintf(stderr, "surf: error sending: %.*s\n", ret-2, msg+2); } void |