Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
30bd7c48
Commit
30bd7c48
authored
Apr 22, 2015
by
evoskuil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix integer narrowing issues.
parent
88ac6318
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
34 additions
and
28 deletions
+34
-28
options.cpp
src/options.cpp
+1
-1
plain_server.cpp
src/plain_server.cpp
+1
-1
socks.cpp
src/socks.cpp
+11
-8
socks.hpp
src/socks.hpp
+5
-5
socks_connecter.cpp
src/socks_connecter.cpp
+3
-3
stdint.hpp
src/stdint.hpp
+4
-0
stream.cpp
src/stream.cpp
+2
-3
stream_engine.cpp
src/stream_engine.cpp
+1
-1
tcp_connecter.cpp
src/tcp_connecter.cpp
+2
-2
tcp_listener.cpp
src/tcp_listener.cpp
+3
-3
zmq_utils.cpp
src/zmq_utils.cpp
+1
-1
No files found.
src/options.cpp
View file @
30bd7c48
...
...
@@ -96,7 +96,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
case
ZMQ_IDENTITY
:
// Identity is any binary string from 1 to 255 octets
if
(
optvallen_
>
0
&&
optvallen_
<
256
)
{
identity_size
=
optvallen_
;
identity_size
=
(
unsigned
char
)
optvallen_
;
memcpy
(
identity
,
optval_
,
identity_size
);
return
0
;
}
...
...
src/plain_server.cpp
View file @
30bd7c48
...
...
@@ -265,7 +265,7 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
zmq_assert
(
rc
==
0
);
char
*
msg_data
=
static_cast
<
char
*>
(
msg_
->
data
());
memcpy
(
msg_data
,
"
\5
ERROR"
,
6
);
msg_data
[
6
]
=
status_code
.
length
();
msg_data
[
6
]
=
(
char
)
status_code
.
length
();
memcpy
(
msg_data
+
7
,
status_code
.
c_str
(),
status_code
.
length
());
return
0
;
}
...
...
src/socks.cpp
View file @
30bd7c48
...
...
@@ -37,12 +37,10 @@ zmq::socks_greeting_t::socks_greeting_t (uint8_t method_) :
}
zmq
::
socks_greeting_t
::
socks_greeting_t
(
uint8_t
*
methods_
,
size
_t
num_methods_
)
uint8_t
*
methods_
,
uint8
_t
num_methods_
)
:
num_methods
(
num_methods_
)
{
zmq_assert
(
num_methods_
<=
255
);
for
(
size_t
i
=
0
;
i
<
num_methods_
;
i
++
)
for
(
uint8_t
i
=
0
;
i
<
num_methods_
;
i
++
)
methods
[
i
]
=
methods_
[
i
];
}
...
...
@@ -55,8 +53,8 @@ void zmq::socks_greeting_encoder_t::encode (const socks_greeting_t &greeting_)
uint8_t
*
ptr
=
buf
;
*
ptr
++
=
0x05
;
*
ptr
++
=
greeting_
.
num_methods
;
for
(
size
_t
i
=
0
;
i
<
greeting_
.
num_methods
;
i
++
)
*
ptr
++
=
(
uint8_t
)
greeting_
.
num_methods
;
for
(
uint8
_t
i
=
0
;
i
<
greeting_
.
num_methods
;
i
++
)
*
ptr
++
=
greeting_
.
methods
[
i
];
bytes_encoded
=
2
+
greeting_
.
num_methods
;
...
...
@@ -118,10 +116,13 @@ void zmq::socks_choice_decoder_t::reset ()
bytes_read
=
0
;
}
zmq
::
socks_request_t
::
socks_request_t
(
uint8_t
command_
,
std
::
string
hostname_
,
uint16_t
port_
)
:
command
(
command_
),
hostname
(
hostname_
),
port
(
port_
)
{}
{
zmq_assert
(
hostname_
.
size
()
<=
UINT8_MAX
);
}
zmq
::
socks_request_encoder_t
::
socks_request_encoder_t
()
:
bytes_encoded
(
0
),
bytes_written
(
0
)
...
...
@@ -129,6 +130,8 @@ zmq::socks_request_encoder_t::socks_request_encoder_t ()
void
zmq
::
socks_request_encoder_t
::
encode
(
const
socks_request_t
&
req
)
{
zmq_assert
(
req
.
hostname
.
size
()
<=
UINT8_MAX
);
unsigned
char
*
ptr
=
buf
;
*
ptr
++
=
0x05
;
*
ptr
++
=
req
.
command
;
...
...
@@ -163,7 +166,7 @@ void zmq::socks_request_encoder_t::encode (const socks_request_t &req)
}
else
{
*
ptr
++
=
0x03
;
*
ptr
++
=
req
.
hostname
.
size
();
*
ptr
++
=
(
unsigned
char
)
req
.
hostname
.
size
();
memcpy
(
ptr
,
req
.
hostname
.
c_str
(),
req
.
hostname
.
size
());
ptr
+=
req
.
hostname
.
size
();
}
...
...
src/socks.hpp
View file @
30bd7c48
...
...
@@ -30,9 +30,9 @@ namespace zmq
struct
socks_greeting_t
{
socks_greeting_t
(
uint8_t
method
);
socks_greeting_t
(
uint8_t
*
methods_
,
size
_t
num_methods_
);
socks_greeting_t
(
uint8_t
*
methods_
,
uint8
_t
num_methods_
);
uint8_t
methods
[
255
];
uint8_t
methods
[
UINT8_MAX
];
const
size_t
num_methods
;
};
...
...
@@ -48,7 +48,7 @@ namespace zmq
private
:
size_t
bytes_encoded
;
size_t
bytes_written
;
uint8_t
buf
[
2
+
255
];
uint8_t
buf
[
2
+
UINT8_MAX
];
};
struct
socks_choice_t
...
...
@@ -94,7 +94,7 @@ namespace zmq
private
:
size_t
bytes_encoded
;
size_t
bytes_written
;
uint8_t
buf
[
4
+
256
+
2
];
uint8_t
buf
[
4
+
UINT8_MAX
+
1
+
2
];
};
struct
socks_response_t
...
...
@@ -116,7 +116,7 @@ namespace zmq
void
reset
();
private
:
uint8_t
buf
[
4
+
256
+
2
];
int8_t
buf
[
4
+
UINT8_MAX
+
1
+
2
];
size_t
bytes_read
;
};
...
...
src/socks_connecter.cpp
View file @
30bd7c48
...
...
@@ -148,7 +148,7 @@ void zmq::socks_connecter_t::in_event ()
// Attach the engine to the corresponding session object.
send_attach
(
session
,
engine
);
socket
->
event_connected
(
endpoint
,
s
);
socket
->
event_connected
(
endpoint
,
(
int
)
s
);
rm_fd
(
handle
);
s
=
-
1
;
...
...
@@ -170,7 +170,7 @@ void zmq::socks_connecter_t::out_event ()
||
status
==
sending_request
);
if
(
status
==
waiting_for_proxy_connection
)
{
const
int
rc
=
check_proxy_connection
();
const
int
rc
=
(
int
)
check_proxy_connection
();
if
(
rc
==
-
1
)
error
();
else
{
...
...
@@ -436,7 +436,7 @@ void zmq::socks_connecter_t::close ()
const
int
rc
=
::
close
(
s
);
errno_assert
(
rc
==
0
);
#endif
socket
->
event_closed
(
endpoint
,
s
);
socket
->
event_closed
(
endpoint
,
(
int
)
s
);
s
=
retired_fd
;
}
...
...
src/stdint.hpp
View file @
30bd7c48
...
...
@@ -59,4 +59,8 @@ typedef unsigned __int64 uint64_t;
#endif
#ifndef UINT8_MAX
#define UINT8_MAX 0xFF
#endif
#endif
src/stream.cpp
View file @
30bd7c48
...
...
@@ -289,14 +289,13 @@ void zmq::stream_t::identify_peer (pipe_t *pipe_)
connect_rid
.
length
());
connect_rid
.
clear
();
outpipes_t
::
iterator
it
=
outpipes
.
find
(
identity
);
if
(
it
!=
outpipes
.
end
())
zmq_assert
(
false
);
zmq_assert
(
it
==
outpipes
.
end
());
}
else
{
put_uint32
(
buffer
+
1
,
next_rid
++
);
identity
=
blob_t
(
buffer
,
sizeof
buffer
);
memcpy
(
options
.
identity
,
identity
.
data
(),
identity
.
size
());
options
.
identity_size
=
identity
.
size
();
options
.
identity_size
=
(
unsigned
char
)
identity
.
size
();
}
pipe_
->
set_identity
(
identity
);
// Add the record into output pipes lookup table
...
...
src/stream_engine.cpp
View file @
30bd7c48
...
...
@@ -928,7 +928,7 @@ void zmq::stream_engine_t::error (error_reason_t reason)
terminator
.
close
();
}
zmq_assert
(
session
);
socket
->
event_disconnected
(
endpoint
,
s
);
socket
->
event_disconnected
(
endpoint
,
(
int
)
s
);
session
->
flush
();
session
->
engine_error
(
reason
);
unplug
();
...
...
src/tcp_connecter.cpp
View file @
30bd7c48
...
...
@@ -138,7 +138,7 @@ void zmq::tcp_connecter_t::out_event ()
// Shut the connecter down.
terminate
();
socket
->
event_connected
(
endpoint
,
fd
);
socket
->
event_connected
(
endpoint
,
(
int
)
fd
);
}
void
zmq
::
tcp_connecter_t
::
timer_event
(
int
id_
)
...
...
@@ -352,6 +352,6 @@ void zmq::tcp_connecter_t::close ()
const
int
rc
=
::
close
(
s
);
errno_assert
(
rc
==
0
);
#endif
socket
->
event_closed
(
endpoint
,
s
);
socket
->
event_closed
(
endpoint
,
(
int
)
s
);
s
=
retired_fd
;
}
src/tcp_listener.cpp
View file @
30bd7c48
...
...
@@ -111,7 +111,7 @@ void zmq::tcp_listener_t::in_event ()
session
->
inc_seqnum
();
launch_child
(
session
);
send_attach
(
session
,
engine
,
false
);
socket
->
event_accepted
(
endpoint
,
fd
);
socket
->
event_accepted
(
endpoint
,
(
int
)
fd
);
}
void
zmq
::
tcp_listener_t
::
close
()
...
...
@@ -124,7 +124,7 @@ void zmq::tcp_listener_t::close ()
int
rc
=
::
close
(
s
);
errno_assert
(
rc
==
0
);
#endif
socket
->
event_closed
(
endpoint
,
s
);
socket
->
event_closed
(
endpoint
,
(
int
)
s
);
s
=
retired_fd
;
}
...
...
@@ -239,7 +239,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
goto
error
;
#endif
socket
->
event_listening
(
endpoint
,
s
);
socket
->
event_listening
(
endpoint
,
(
int
)
s
);
return
0
;
error
:
...
...
src/zmq_utils.cpp
View file @
30bd7c48
...
...
@@ -155,7 +155,7 @@ uint8_t *zmq_z85_decode (uint8_t *dest, const char *string)
}
unsigned
int
byte_nbr
=
0
;
unsigned
int
char_nbr
=
0
;
unsigned
in
t
string_len
=
strlen
(
string
);
size_
t
string_len
=
strlen
(
string
);
uint32_t
value
=
0
;
while
(
char_nbr
<
string_len
)
{
// Accumulate value in base 85
...
...
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