Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
115afdb0
Commit
115afdb0
authored
Jul 11, 2015
by
Paul Sokolovsky
Browse files
unix: socket.getaddrinfo: Port is unsigned value.
Treating it as signed lead to buffer overflow for ports >= 32768.
parent
cf814b2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
unix/modsocket.c
View file @
115afdb0
...
...
@@ -367,9 +367,9 @@ STATIC mp_obj_t mod_socket_getaddrinfo(mp_uint_t n_args, const mp_obj_t *args) {
// getaddrinfo accepts port in string notation, so however
// it may seem stupid, we need to convert int to str
if
(
MP_OBJ_IS_SMALL_INT
(
args
[
1
]))
{
int
port
=
(
short
)
MP_OBJ_SMALL_INT_VALUE
(
args
[
1
]);
unsigned
port
=
(
unsigned
short
)
MP_OBJ_SMALL_INT_VALUE
(
args
[
1
]);
char
buf
[
6
];
sprintf
(
buf
,
"%
d
"
,
port
);
sprintf
(
buf
,
"%
u
"
,
port
);
serv
=
buf
;
hints
.
ai_flags
=
AI_NUMERICSERV
;
#ifdef __UCLIBC_MAJOR__
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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