Fix message sizes for web extension communication
This commit is contained in:
@@ -1853,21 +1853,22 @@ zoom(Client *c, const Arg *a)
|
|||||||
static void
|
static void
|
||||||
msgext(Client *c, char type, const Arg *a)
|
msgext(Client *c, char type, const Arg *a)
|
||||||
{
|
{
|
||||||
static char msg[MSGBUFSZ];
|
static unsigned char msg[MSGBUFSZ];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (spair[0] < 0)
|
if (spair[0] < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((ret = snprintf(msg, sizeof(msg), "%c%c%c", c->pageid, type, a->i))
|
ret = snprintf(msg, sizeof(msg), "%c%c%c",
|
||||||
>= sizeof(msg)) {
|
(unsigned char)c->pageid, type, (signed char)a->i);
|
||||||
|
if (ret >= sizeof(msg)) {
|
||||||
fprintf(stderr, "surf: message too long: %d\n", ret);
|
fprintf(stderr, "surf: message too long: %d\n", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send(spair[0], msg, ret, 0) != ret)
|
if (send(spair[0], msg, ret, 0) != ret)
|
||||||
fprintf(stderr, "surf: error sending: %u%c%d (%d)\n",
|
fprintf(stderr, "surf: error sending: %hhu/%c/%d (%d)\n",
|
||||||
c->pageid, type, a->i, ret);
|
(unsigned char)c->pageid, type, a->i, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+3
-3
@@ -39,7 +39,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msgsz < 2) {
|
if (msgsz < 2) {
|
||||||
fprintf(stderr, "webext: readsock: message too short: %d\n",
|
fprintf(stderr, "webext: readsock: message too short: %lu\n",
|
||||||
msgsz);
|
msgsz);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
if (msgsz != 3)
|
if (msgsz != 3)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
snprintf(js, sizeof(js),
|
snprintf(js, sizeof(js),
|
||||||
"window.scrollBy(window.innerWidth/100*%d,0);",
|
"window.scrollBy(window.innerWidth/100*%hhd,0);",
|
||||||
msg[2]);
|
msg[2]);
|
||||||
jsc_context_evaluate(jsc, js, -1);
|
jsc_context_evaluate(jsc, js, -1);
|
||||||
break;
|
break;
|
||||||
@@ -62,7 +62,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
if (msgsz != 3)
|
if (msgsz != 3)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
snprintf(js, sizeof(js),
|
snprintf(js, sizeof(js),
|
||||||
"window.scrollBy(0,window.innerHeight/100*%d);",
|
"window.scrollBy(0,window.innerHeight/100*%hhd);",
|
||||||
msg[2]);
|
msg[2]);
|
||||||
jsc_context_evaluate(jsc, js, -1);
|
jsc_context_evaluate(jsc, js, -1);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user