switch to gnutls to avoid gcrypt state corruption

v1
Tony Olagbaiye 6 years ago
parent 47a8e86a34
commit b87ddd7a6c

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

@ -1,4 +1,5 @@
#include <libwebsockets.h>
#include <json.h>
#include <string.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);
break;
/* chunks of chunked content, with header removed */
/* data is never chunked */
case LWS_CALLBACK_CLIENT_RECEIVE:
weechat_printf(
workspace->buffer,
@ -40,25 +41,25 @@ static int callback_ws(struct lws* wsi, enum lws_callback_reasons reason,
weechat_prefix("network"), SLACK_PLUGIN_NAME,
(const char *)in);
{
struct t_json_chunk *new_chunk, *last_chunk;
char *json_string;
json_object *response, *type;
new_chunk = malloc(sizeof(*new_chunk));
new_chunk->data = malloc((1024 * sizeof(char)) + 1);
new_chunk->data[0] = '\0';
new_chunk->next = NULL;
json_string = strdup((const char *)in);
strncat(new_chunk->data, in, (int)len);
if (workspace->json_chunks)
{
for (last_chunk = workspace->json_chunks; last_chunk->next;
last_chunk = last_chunk->next);
last_chunk->next = new_chunk;
}
else
response = json_tokener_parse(json_string);
type = json_object_object_get(response, "type");
if (!type)
{
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 */

@ -34,7 +34,7 @@ static inline int json_valid(json_object *object)
{
weechat_printf(
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);
return 0;
}

@ -29,7 +29,7 @@ static inline int json_valid(json_object *object, struct t_slack_workspace *work
{
weechat_printf(
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);
return 0;
}

Loading…
Cancel
Save