aboutsummaryrefslogtreecommitdiff
path: root/weechat/net.c
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-29 22:32:24 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-29 22:32:24 +0200
commitb12ea9fb05e636213b35d46ddaec3e255e1a6992 (patch)
treeac0ed1f5c35cd3c99edf6b6eb9ad8d32a9ad6082 /weechat/net.c
parent0d07fa5da9f4c287410ce68d9d89da5c436fcc68 (diff)
weechat: Protocol version 2, display replies
Diffstat (limited to 'weechat/net.c')
-rw-r--r--weechat/net.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/weechat/net.c b/weechat/net.c
index 897655a..ce8da6a 100644
--- a/weechat/net.c
+++ b/weechat/net.c
@@ -220,9 +220,9 @@ void net_handle_recv(int fd,const char *msg){
}
const char *roomp=p+1;
p=strchr(roomp,' ');
- const char *q,*r,*s;
+ const char *q,*r,*s,*t;
if(p==NULL||(q=strchr(p+1,' '))==NULL||(r=strchr(q+1,' '))==NULL
- ||(s=strchr(r+1,' '))==NULL){
+ ||(s=strchr(r+1,' '))==NULL||(t=strchr(s+1,' '))==NULL){
debugf("net_handle_recv: not enough arguments to 'message' <%s>\n",msg);
return;
}
@@ -233,10 +233,12 @@ void net_handle_recv(int fd,const char *msg){
i64 stamplen=r-stampp;
const char *msgidp=r+1;
i64 msgidlen=s-msgidp;
- const char *textp=s+1;
+ const char *replyidp=s+1;
+ i64 replyidlen=t-replyidp;
+ const char *textp=t+1;
i64 textlen=msglen-(textp-msg);
- (void)msgidp; (void)msgidlen;
+ (void)msgidp; (void)msgidlen; (void)replyidlen;
struct net_response res;
res.type=NET_MESSAGE;
@@ -246,6 +248,16 @@ void net_handle_recv(int fd,const char *msg){
debugf("net_handle_recv: timestamp not a number in 'message' <%s>\n",msg);
return;
}
+ res.msgid=strtoll(msgidp,(char**)&endp,10);
+ if(endp-msgidp!=msgidlen){
+ debugf("net_handle_recv: msgid not a number in 'message' <%s>\n",msg);
+ return;
+ }
+ res.replyid=strtoll(replyidp,(char**)&endp,10);
+ if(endp-replyidp!=replyidlen){
+ debugf("net_handle_recv: replyid not a number in 'message' <%s>\n",msg);
+ return;
+ }
res.room=malloc(roomlen+1);
res.username=malloc(usernamelen+1);
res.message=malloc(textlen+1);
@@ -276,9 +288,9 @@ void net_handle_recv(int fd,const char *msg){
}
const char *roomp=p+1;
p=strchr(roomp,' ');
- const char *q,*r,*s;
+ const char *q,*r,*s,*t;
if(p==NULL||(q=strchr(p+1,' '))==NULL||(r=strchr(q+1,' '))==NULL
- ||(s=strchr(r+1,' '))==NULL){
+ ||(s=strchr(r+1,' '))==NULL||(t=strchr(s+1,' '))==NULL){
debugf("net_handle_recv: not enough arguments to 'history_message' <%s>\n",msg);
return;
}
@@ -289,11 +301,11 @@ void net_handle_recv(int fd,const char *msg){
i64 stamplen=r-stampp;
const char *msgidp=r+1;
i64 msgidlen=s-msgidp;
- const char *textp=s+1;
+ const char *replyidp=s+1;
+ i64 replyidlen=t-replyidp;
+ const char *textp=t+1;
i64 textlen=msglen-(textp-msg);
- (void)msgidp; (void)msgidlen;
-
struct net_response res;
res.type=NET_HISTORY;
const char *endp;
@@ -302,6 +314,16 @@ void net_handle_recv(int fd,const char *msg){
debugf("net_handle_recv: timestamp not a number in 'history_message' <%s>\n",msg);
return;
}
+ res.msgid=strtoll(msgidp,(char**)&endp,10);
+ if(endp-msgidp!=msgidlen){
+ debugf("net_handle_recv: msgid not a number in 'history_message' <%s>\n",msg);
+ return;
+ }
+ res.replyid=strtoll(replyidp,(char**)&endp,10);
+ if(endp-replyidp!=replyidlen){
+ debugf("net_handle_recv: replyid not a number in 'history_message' <%s>\n",msg);
+ return;
+ }
res.room=malloc(roomlen+1);
res.username=malloc(usernamelen+1);
res.message=malloc(textlen+1);