switch to gnutls to avoid gcrypt state corruption

v1
Tony Olagbaiye 7 years ago
parent 47a8e86a34
commit b87ddd7a6c

@ -3,7 +3,7 @@ CXX=clang++
RM=rm -f RM=rm -f
CFLAGS=-fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -I libwebsockets/include -I json-c CFLAGS=-fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -I libwebsockets/include -I json-c
LDFLAGS=-shared -g LDFLAGS=-shared -g
LDLIBS=-lssl LDLIBS=-lgnutls
SRCS=slack.c \ SRCS=slack.c \
slack-api.c \ slack-api.c \

@ -1,4 +1,5 @@
#include <libwebsockets.h> #include <libwebsockets.h>
#include <json.h>
#include <string.h> #include <string.h>
#include "weechat-plugin.h" #include "weechat-plugin.h"
@ -32,7 +33,7 @@ static int callback_ws(struct lws* wsi, enum lws_callback_reasons reason,
weechat_prefix("network"), SLACK_PLUGIN_NAME); weechat_prefix("network"), SLACK_PLUGIN_NAME);
break; break;
/* chunks of chunked content, with header removed */ /* data is never chunked */
case LWS_CALLBACK_CLIENT_RECEIVE: case LWS_CALLBACK_CLIENT_RECEIVE:
weechat_printf( weechat_printf(
workspace->buffer, workspace->buffer,
@ -40,25 +41,25 @@ static int callback_ws(struct lws* wsi, enum lws_callback_reasons reason,
weechat_prefix("network"), SLACK_PLUGIN_NAME, weechat_prefix("network"), SLACK_PLUGIN_NAME,
(const char *)in); (const char *)in);
{ {
struct t_json_chunk *new_chunk, *last_chunk; char *json_string;
json_object *response, *type;
new_chunk = malloc(sizeof(*new_chunk)); json_string = strdup((const char *)in);
new_chunk->data = malloc((1024 * sizeof(char)) + 1);
new_chunk->data[0] = '\0';
new_chunk->next = NULL;
strncat(new_chunk->data, in, (int)len); response = json_tokener_parse(json_string);
type = json_object_object_get(response, "type");
if (workspace->json_chunks) if (!type)
{
for (last_chunk = workspace->json_chunks; last_chunk->next;
last_chunk = last_chunk->next);
last_chunk->next = new_chunk;
}
else
{ {
workspace->json_chunks = new_chunk; weechat_printf(
workspace->buffer,
_("%s%s: unexpected data received from websocket: closing"),
weechat_prefix("error"), SLACK_PLUGIN_NAME);
json_object_put(response);
free(json_string);
return -1;
} }
free(json_string);
} }
return 0; /* don't passthru */ return 0; /* don't passthru */

@ -34,7 +34,7 @@ static inline int json_valid(json_object *object)
{ {
weechat_printf( weechat_printf(
NULL, NULL,
_("%s%s: Error retrieving workspace info: unexpected response from server"), _("%s%s: error retrieving workspace info: unexpected response from server"),
weechat_prefix("error"), SLACK_PLUGIN_NAME); weechat_prefix("error"), SLACK_PLUGIN_NAME);
return 0; return 0;
} }

@ -29,7 +29,7 @@ static inline int json_valid(json_object *object, struct t_slack_workspace *work
{ {
weechat_printf( weechat_printf(
workspace->buffer, workspace->buffer,
_("%s%s: Error requesting websocket: unexpected response from server"), _("%s%s: error requesting websocket: unexpected response from server"),
weechat_prefix("error"), SLACK_PLUGIN_NAME); weechat_prefix("error"), SLACK_PLUGIN_NAME);
return 0; return 0;
} }

Loading…
Cancel
Save