Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
6d64a3b6
Unverified
Commit
6d64a3b6
authored
Feb 20, 2023
by
David McCurley
Committed by
GitHub
Feb 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WiFiUDP:parsePacket() Crashfix (#7847)
* Update WiFiUdp.cpp * Update WiFiUdp.cpp
parent
b8ea455f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
libraries/WiFi/src/WiFiUdp.cpp
libraries/WiFi/src/WiFiUdp.cpp
+7
-5
No files found.
libraries/WiFi/src/WiFiUdp.cpp
View file @
6d64a3b6
...
...
@@ -16,7 +16,9 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WiFiUdp.h"
#include <new> //std::nothrow
#include <lwip/sockets.h>
#include <lwip/netdb.h>
#include <errno.h>
...
...
@@ -207,12 +209,12 @@ int WiFiUDP::parsePacket(){
return
0
;
struct
sockaddr_in
si_other
;
int
slen
=
sizeof
(
si_other
)
,
len
;
char
*
buf
=
new
char
[
1460
]
;
if
(
!
buf
){
char
*
buf
=
(
char
*
)
malloc
(
1460
)
;
if
(
!
buf
)
{
return
0
;
}
if
((
len
=
recvfrom
(
udp_server
,
buf
,
1460
,
MSG_DONTWAIT
,
(
struct
sockaddr
*
)
&
si_other
,
(
socklen_t
*
)
&
slen
))
==
-
1
){
delete
[]
buf
;
free
(
buf
)
;
if
(
errno
==
EWOULDBLOCK
){
return
0
;
}
...
...
@@ -222,10 +224,10 @@ int WiFiUDP::parsePacket(){
remote_ip
=
IPAddress
(
si_other
.
sin_addr
.
s_addr
);
remote_port
=
ntohs
(
si_other
.
sin_port
);
if
(
len
>
0
)
{
rx_buffer
=
new
cbuf
(
len
);
rx_buffer
=
new
(
std
::
nothrow
)
cbuf
(
len
);
rx_buffer
->
write
(
buf
,
len
);
}
delete
[]
buf
;
free
(
buf
)
;
return
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