Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
6645291b
Commit
6645291b
authored
Jul 11, 2018
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a memory allocation issue in websockets
parent
09db5293
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
WebSocket.c
src/WebSocket.c
+15
-3
No files found.
src/WebSocket.c
View file @
6645291b
/*******************************************************************************
* Copyright (c) 2018 Wind River Systems, Inc. All Rights Reserved.
* Copyright (c) 2018 Wind River Systems, Inc.
and others.
All Rights Reserved.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
...
...
@@ -12,6 +12,7 @@
*
* Contributors:
* Keith Holman - initial implementation and documentation
* Ian Craggs - use memory tracking
*******************************************************************************/
#include <stdint.h>
...
...
@@ -82,6 +83,8 @@
#include <openssl/rand.h>
#endif
/* if defined(OPENSSL) */
#include "Heap.h"
/** @brief raw uuid type */
typedef
unsigned
char
uuid_t
[
16
];
...
...
@@ -308,7 +311,10 @@ int WebSocket_connect( networkHandles *net, const char *uri )
const
char
*
topic
=
NULL
;
/* Generate UUID */
net
->
websocket_key
=
realloc
(
net
->
websocket_key
,
25u
);
if
(
net
->
websocket_key
==
NULL
)
net
->
websocket_key
=
malloc
(
25u
);
else
net
->
websocket_key
=
realloc
(
net
->
websocket_key
,
25u
);
#if defined(WIN32) || defined(WIN64)
UUID
uuid
;
ZeroMemory
(
&
uuid
,
sizeof
(
UUID
)
);
...
...
@@ -426,7 +432,10 @@ void WebSocket_close(networkHandles *net, int status_code, const char *reason)
free
(
buf0
);
}
if
(
net
->
websocket_key
)
{
free
(
net
->
websocket_key
);
net
->
websocket_key
=
NULL
;
}
}
/**
...
...
@@ -784,7 +793,10 @@ int WebSocket_receiveFrame(networkHandles *net,
if
(
res
)
cur_len
=
res
->
len
;
res
=
realloc
(
res
,
sizeof
(
struct
ws_frame
)
+
cur_len
+
len
);
if
(
res
==
NULL
)
res
=
malloc
(
sizeof
(
struct
ws_frame
)
+
cur_len
+
len
);
else
res
=
realloc
(
res
,
sizeof
(
struct
ws_frame
)
+
cur_len
+
len
);
memcpy
(
(
unsigned
char
*
)
res
+
sizeof
(
struct
ws_frame
)
+
cur_len
,
b
,
len
);
res
->
pos
=
0u
;
res
->
len
=
cur_len
+
len
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment