/src/librabbitmq/librabbitmq/amqp_private.h
Line | Count | Source |
1 | | // Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. |
2 | | // SPDX-License-Identifier: mit |
3 | | |
4 | | #ifndef librabbitmq_amqp_private_h |
5 | | #define librabbitmq_amqp_private_h |
6 | | |
7 | | #ifdef HAVE_CONFIG_H |
8 | | #include "config.h" |
9 | | #endif |
10 | | |
11 | | #define AMQ_COPYRIGHT \ |
12 | 0 | "Copyright (c) 2007-2014 VMWare Inc, Tony Garnock-Jones," \ |
13 | 0 | " and Alan Antonuk." |
14 | | |
15 | | #include "rabbitmq-c/amqp.h" |
16 | | #include "rabbitmq-c/framing.h" |
17 | | #include <string.h> |
18 | | |
19 | | #if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) |
20 | | #ifndef WINVER |
21 | | /* WINVER 0x0502 is WinXP SP2+, Windows Server 2003 SP1+ |
22 | | * See: |
23 | | * http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx#macros_for_conditional_declarations |
24 | | */ |
25 | | #define WINVER 0x0502 |
26 | | #endif |
27 | | #ifndef WIN32_LEAN_AND_MEAN |
28 | | #define WIN32_LEAN_AND_MEAN |
29 | | #endif |
30 | | #include <winsock2.h> |
31 | | #else |
32 | | #include <arpa/inet.h> |
33 | | #include <sys/uio.h> |
34 | | #endif |
35 | | |
36 | | /* GCC attributes */ |
37 | | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) |
38 | | #define AMQP_NORETURN __attribute__((__noreturn__)) |
39 | | #define AMQP_UNUSED __attribute__((__unused__)) |
40 | | #elif defined(_MSC_VER) |
41 | | #define AMQP_NORETURN __declspec(noreturn) |
42 | | #define AMQP_UNUSED __pragma(warning(suppress : 4100)) |
43 | | #else |
44 | | #define AMQP_NORETURN |
45 | | #define AMQP_UNUSED |
46 | | #endif |
47 | | |
48 | | #if (defined(_MSC_VER) && (_MSC_VER <= 1800)) || \ |
49 | | (defined(__BORLANDC__) && (__BORLANDC__ <= 0x0564)) |
50 | | #define inline __inline |
51 | | #endif |
52 | | |
53 | | char *amqp_os_error_string(int err); |
54 | | |
55 | | #include "amqp_socket.h" |
56 | | #include "amqp_time.h" |
57 | | |
58 | | /* |
59 | | * Connection states: XXX FIX THIS |
60 | | * |
61 | | * - CONNECTION_STATE_INITIAL: The initial state, when we cannot be |
62 | | * sure if the next thing we will get is the first AMQP frame, or a |
63 | | * protocol header from the server. |
64 | | * |
65 | | * - CONNECTION_STATE_IDLE: The normal state between |
66 | | * frames. Connections may only be reconfigured, and the |
67 | | * connection's pools recycled, when in this state. Whenever we're |
68 | | * in this state, the inbound_buffer's bytes pointer must be NULL; |
69 | | * any other state, and it must point to a block of memory allocated |
70 | | * from the frame_pool. |
71 | | * |
72 | | * - CONNECTION_STATE_HEADER: Some bytes of an incoming frame have |
73 | | * been seen, but not a complete frame header's worth. |
74 | | * |
75 | | * - CONNECTION_STATE_BODY: A complete frame header has been seen, but |
76 | | * the frame is not yet complete. When it is completed, it will be |
77 | | * returned, and the connection will return to IDLE state. |
78 | | * |
79 | | */ |
80 | | typedef enum amqp_connection_state_enum_ { |
81 | | CONNECTION_STATE_IDLE = 0, |
82 | | CONNECTION_STATE_INITIAL, |
83 | | CONNECTION_STATE_HEADER, |
84 | | CONNECTION_STATE_BODY |
85 | | } amqp_connection_state_enum; |
86 | | |
87 | | typedef enum amqp_status_private_enum_ { |
88 | | /* 0x00xx -> AMQP_STATUS_*/ |
89 | | /* 0x01xx -> AMQP_STATUS_TCP_* */ |
90 | | /* 0x02xx -> AMQP_STATUS_SSL_* */ |
91 | | AMQP_PRIVATE_STATUS_SOCKET_NEEDREAD = -0x1301, |
92 | | AMQP_PRIVATE_STATUS_SOCKET_NEEDWRITE = -0x1302 |
93 | | } amqp_status_private_enum; |
94 | | |
95 | | /* 7 bytes up front, then payload, then 1 byte footer */ |
96 | 319k | #define HEADER_SIZE 7 |
97 | 142k | #define FOOTER_SIZE 1 |
98 | | |
99 | 39 | #define AMQP_PSEUDOFRAME_PROTOCOL_HEADER 'A' |
100 | | |
101 | | typedef struct amqp_link_t_ { |
102 | | struct amqp_link_t_ *next; |
103 | | void *data; |
104 | | } amqp_link_t; |
105 | | |
106 | 238k | #define POOL_TABLE_SIZE 16 |
107 | | |
108 | | typedef struct amqp_pool_table_entry_t_ { |
109 | | struct amqp_pool_table_entry_t_ *next; |
110 | | amqp_pool_t pool; |
111 | | amqp_channel_t channel; |
112 | | } amqp_pool_table_entry_t; |
113 | | |
114 | | struct amqp_connection_state_t_ { |
115 | | amqp_pool_table_entry_t *pool_table[POOL_TABLE_SIZE]; |
116 | | |
117 | | amqp_connection_state_enum state; |
118 | | |
119 | | int channel_max; |
120 | | int frame_max; |
121 | | |
122 | | /* Heartbeat interval in seconds. If this is <= 0, then heartbeats are not |
123 | | * enabled, and next_recv_heartbeat and next_send_heartbeat are set to |
124 | | * infinite */ |
125 | | int heartbeat; |
126 | | amqp_time_t next_recv_heartbeat; |
127 | | amqp_time_t next_send_heartbeat; |
128 | | |
129 | | /* buffer for holding frame headers. Allows us to delay allocating |
130 | | * the raw frame buffer until the type, channel, and size are all known |
131 | | */ |
132 | | char header_buffer[HEADER_SIZE + 1]; |
133 | | amqp_bytes_t inbound_buffer; |
134 | | |
135 | | size_t inbound_offset; |
136 | | size_t target_size; |
137 | | |
138 | | amqp_bytes_t outbound_buffer; |
139 | | |
140 | | amqp_socket_t *socket; |
141 | | |
142 | | amqp_bytes_t sock_inbound_buffer; |
143 | | size_t sock_inbound_offset; |
144 | | size_t sock_inbound_limit; |
145 | | |
146 | | amqp_link_t *first_queued_frame; |
147 | | amqp_link_t *last_queued_frame; |
148 | | |
149 | | amqp_rpc_reply_t most_recent_api_result; |
150 | | |
151 | | amqp_table_t server_properties; |
152 | | amqp_table_t client_properties; |
153 | | amqp_pool_t properties_pool; |
154 | | |
155 | | struct timeval *handshake_timeout; |
156 | | struct timeval internal_handshake_timeout; |
157 | | struct timeval *rpc_timeout; |
158 | | struct timeval internal_rpc_timeout; |
159 | | }; |
160 | | |
161 | | amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, |
162 | | amqp_channel_t channel); |
163 | | amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, |
164 | | amqp_channel_t channel); |
165 | | |
166 | 4.99k | static inline int amqp_heartbeat_send(amqp_connection_state_t state) { |
167 | 4.99k | return state->heartbeat; |
168 | 4.99k | } Unexecuted instantiation: amqp_framing.c:amqp_heartbeat_send Unexecuted instantiation: amqp_mem.c:amqp_heartbeat_send Unexecuted instantiation: amqp_socket.c:amqp_heartbeat_send Unexecuted instantiation: amqp_table.c:amqp_heartbeat_send Unexecuted instantiation: amqp_api.c:amqp_heartbeat_send amqp_connection.c:amqp_heartbeat_send Line | Count | Source | 166 | 4.99k | static inline int amqp_heartbeat_send(amqp_connection_state_t state) { | 167 | 4.99k | return state->heartbeat; | 168 | 4.99k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_heartbeat_send Unexecuted instantiation: fuzz_server.c:amqp_heartbeat_send Unexecuted instantiation: amqp_url.c:amqp_heartbeat_send |
169 | | |
170 | 5.03k | static inline int amqp_heartbeat_recv(amqp_connection_state_t state) { |
171 | 5.03k | return 2 * state->heartbeat; |
172 | 5.03k | } Unexecuted instantiation: amqp_framing.c:amqp_heartbeat_recv Unexecuted instantiation: amqp_mem.c:amqp_heartbeat_recv amqp_socket.c:amqp_heartbeat_recv Line | Count | Source | 170 | 44 | static inline int amqp_heartbeat_recv(amqp_connection_state_t state) { | 171 | 44 | return 2 * state->heartbeat; | 172 | 44 | } |
Unexecuted instantiation: amqp_table.c:amqp_heartbeat_recv Unexecuted instantiation: amqp_api.c:amqp_heartbeat_recv amqp_connection.c:amqp_heartbeat_recv Line | Count | Source | 170 | 4.99k | static inline int amqp_heartbeat_recv(amqp_connection_state_t state) { | 171 | 4.99k | return 2 * state->heartbeat; | 172 | 4.99k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_heartbeat_recv Unexecuted instantiation: fuzz_server.c:amqp_heartbeat_recv Unexecuted instantiation: amqp_url.c:amqp_heartbeat_recv |
173 | | |
174 | | int amqp_try_recv(amqp_connection_state_t state); |
175 | | |
176 | 95.7M | static inline void *amqp_offset(void *data, size_t offset) { |
177 | 95.7M | return (char *)data + offset; |
178 | 95.7M | } amqp_framing.c:amqp_offset Line | Count | Source | 176 | 120k | static inline void *amqp_offset(void *data, size_t offset) { | 177 | 120k | return (char *)data + offset; | 178 | 120k | } |
Unexecuted instantiation: amqp_mem.c:amqp_offset Unexecuted instantiation: amqp_socket.c:amqp_offset Line | Count | Source | 176 | 95.0M | static inline void *amqp_offset(void *data, size_t offset) { | 177 | 95.0M | return (char *)data + offset; | 178 | 95.0M | } |
Unexecuted instantiation: amqp_api.c:amqp_offset amqp_connection.c:amqp_offset Line | Count | Source | 176 | 564k | static inline void *amqp_offset(void *data, size_t offset) { | 177 | 564k | return (char *)data + offset; | 178 | 564k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_offset Unexecuted instantiation: fuzz_server.c:amqp_offset Unexecuted instantiation: amqp_url.c:amqp_offset |
179 | | |
180 | | /* This macro defines the encoding and decoding functions associated with a |
181 | | simple type. */ |
182 | | |
183 | | #define DECLARE_CODEC_BASE_TYPE(bits) \ |
184 | | \ |
185 | | static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \ |
186 | 12.3M | uint##bits##_t input) { \ |
187 | 12.3M | size_t o = *offset; \ |
188 | 12.3M | if ((*offset = o + bits / 8) <= encoded.len) { \ |
189 | 12.3M | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ |
190 | 12.3M | return 1; \ |
191 | 12.3M | } \ |
192 | 12.3M | return 0; \ |
193 | 12.3M | } \ amqp_framing.c:amqp_encode_8 Line | Count | Source | 186 | 8.12k | uint##bits##_t input) { \ | 187 | 8.12k | size_t o = *offset; \ | 188 | 8.12k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 8.12k | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 8.12k | return 1; \ | 191 | 8.12k | } \ | 192 | 8.12k | return 0; \ | 193 | 8.12k | } \ |
amqp_framing.c:amqp_encode_32 Line | Count | Source | 186 | 791 | uint##bits##_t input) { \ | 187 | 791 | size_t o = *offset; \ | 188 | 791 | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 791 | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 791 | return 1; \ | 191 | 791 | } \ | 192 | 791 | return 0; \ | 193 | 791 | } \ |
amqp_framing.c:amqp_encode_16 Line | Count | Source | 186 | 1.91k | uint##bits##_t input) { \ | 187 | 1.91k | size_t o = *offset; \ | 188 | 1.91k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 1.91k | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 1.91k | return 1; \ | 191 | 1.91k | } \ | 192 | 1.91k | return 0; \ | 193 | 1.91k | } \ |
amqp_framing.c:amqp_encode_64 Line | Count | Source | 186 | 526 | uint##bits##_t input) { \ | 187 | 526 | size_t o = *offset; \ | 188 | 526 | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 526 | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 526 | return 1; \ | 191 | 526 | } \ | 192 | 526 | return 0; \ | 193 | 526 | } \ |
Unexecuted instantiation: amqp_mem.c:amqp_encode_8 Unexecuted instantiation: amqp_mem.c:amqp_encode_16 Unexecuted instantiation: amqp_mem.c:amqp_encode_32 Unexecuted instantiation: amqp_mem.c:amqp_encode_64 Unexecuted instantiation: amqp_socket.c:amqp_encode_8 Unexecuted instantiation: amqp_socket.c:amqp_encode_16 Unexecuted instantiation: amqp_socket.c:amqp_encode_32 Unexecuted instantiation: amqp_socket.c:amqp_encode_64 amqp_table.c:amqp_encode_8 Line | Count | Source | 186 | 11.1M | uint##bits##_t input) { \ | 187 | 11.1M | size_t o = *offset; \ | 188 | 11.1M | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 11.1M | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 11.1M | return 1; \ | 191 | 11.1M | } \ | 192 | 11.1M | return 0; \ | 193 | 11.1M | } \ |
amqp_table.c:amqp_encode_32 Line | Count | Source | 186 | 737k | uint##bits##_t input) { \ | 187 | 737k | size_t o = *offset; \ | 188 | 737k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 737k | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 737k | return 1; \ | 191 | 737k | } \ | 192 | 737k | return 0; \ | 193 | 737k | } \ |
amqp_table.c:amqp_encode_16 Line | Count | Source | 186 | 258k | uint##bits##_t input) { \ | 187 | 258k | size_t o = *offset; \ | 188 | 258k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 258k | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 258k | return 1; \ | 191 | 258k | } \ | 192 | 258k | return 0; \ | 193 | 258k | } \ |
amqp_table.c:amqp_encode_64 Line | Count | Source | 186 | 198k | uint##bits##_t input) { \ | 187 | 198k | size_t o = *offset; \ | 188 | 198k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 189 | 198k | amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ | 190 | 198k | return 1; \ | 191 | 198k | } \ | 192 | 198k | return 0; \ | 193 | 198k | } \ |
Unexecuted instantiation: amqp_api.c:amqp_encode_8 Unexecuted instantiation: amqp_api.c:amqp_encode_16 Unexecuted instantiation: amqp_api.c:amqp_encode_32 Unexecuted instantiation: amqp_api.c:amqp_encode_64 Unexecuted instantiation: amqp_connection.c:amqp_encode_8 Unexecuted instantiation: amqp_connection.c:amqp_encode_16 Unexecuted instantiation: amqp_connection.c:amqp_encode_32 Unexecuted instantiation: amqp_connection.c:amqp_encode_64 Unexecuted instantiation: amqp_tcp_socket.c:amqp_encode_8 Unexecuted instantiation: amqp_tcp_socket.c:amqp_encode_16 Unexecuted instantiation: amqp_tcp_socket.c:amqp_encode_32 Unexecuted instantiation: amqp_tcp_socket.c:amqp_encode_64 Unexecuted instantiation: fuzz_server.c:amqp_encode_8 Unexecuted instantiation: fuzz_server.c:amqp_encode_16 Unexecuted instantiation: fuzz_server.c:amqp_encode_32 Unexecuted instantiation: fuzz_server.c:amqp_encode_64 Unexecuted instantiation: amqp_url.c:amqp_encode_8 Unexecuted instantiation: amqp_url.c:amqp_encode_16 Unexecuted instantiation: amqp_url.c:amqp_encode_32 Unexecuted instantiation: amqp_url.c:amqp_encode_64 |
194 | | \ |
195 | | static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \ |
196 | 81.6M | uint##bits##_t *output) { \ |
197 | 81.6M | size_t o = *offset; \ |
198 | 81.6M | if ((*offset = o + bits / 8) <= encoded.len) { \ |
199 | 81.6M | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ |
200 | 81.6M | return 1; \ |
201 | 81.6M | } \ |
202 | 81.6M | return 0; \ |
203 | 81.6M | } amqp_framing.c:amqp_decode_8 Line | Count | Source | 196 | 47.5k | uint##bits##_t *output) { \ | 197 | 47.5k | size_t o = *offset; \ | 198 | 47.5k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 45.9k | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 45.9k | return 1; \ | 201 | 45.9k | } \ | 202 | 47.5k | return 0; \ | 203 | 47.5k | } |
amqp_framing.c:amqp_decode_32 Line | Count | Source | 196 | 6.44k | uint##bits##_t *output) { \ | 197 | 6.44k | size_t o = *offset; \ | 198 | 6.44k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 6.14k | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 6.14k | return 1; \ | 201 | 6.14k | } \ | 202 | 6.44k | return 0; \ | 203 | 6.44k | } |
amqp_framing.c:amqp_decode_16 Line | Count | Source | 196 | 17.8k | uint##bits##_t *output) { \ | 197 | 17.8k | size_t o = *offset; \ | 198 | 17.8k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 17.5k | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 17.5k | return 1; \ | 201 | 17.5k | } \ | 202 | 17.8k | return 0; \ | 203 | 17.8k | } |
amqp_framing.c:amqp_decode_64 Line | Count | Source | 196 | 2.69k | uint##bits##_t *output) { \ | 197 | 2.69k | size_t o = *offset; \ | 198 | 2.69k | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 2.57k | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 2.57k | return 1; \ | 201 | 2.57k | } \ | 202 | 2.69k | return 0; \ | 203 | 2.69k | } |
Unexecuted instantiation: amqp_mem.c:amqp_decode_8 Unexecuted instantiation: amqp_mem.c:amqp_decode_16 Unexecuted instantiation: amqp_mem.c:amqp_decode_32 Unexecuted instantiation: amqp_mem.c:amqp_decode_64 Unexecuted instantiation: amqp_socket.c:amqp_decode_8 Unexecuted instantiation: amqp_socket.c:amqp_decode_16 Unexecuted instantiation: amqp_socket.c:amqp_decode_32 Unexecuted instantiation: amqp_socket.c:amqp_decode_64 amqp_table.c:amqp_decode_32 Line | Count | Source | 196 | 2.53M | uint##bits##_t *output) { \ | 197 | 2.53M | size_t o = *offset; \ | 198 | 2.53M | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 2.53M | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 2.53M | return 1; \ | 201 | 2.53M | } \ | 202 | 2.53M | return 0; \ | 203 | 2.53M | } |
amqp_table.c:amqp_decode_8 Line | Count | Source | 196 | 75.5M | uint##bits##_t *output) { \ | 197 | 75.5M | size_t o = *offset; \ | 198 | 75.5M | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 75.5M | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 75.5M | return 1; \ | 201 | 75.5M | } \ | 202 | 75.5M | return 0; \ | 203 | 75.5M | } |
amqp_table.c:amqp_decode_16 Line | Count | Source | 196 | 2.40M | uint##bits##_t *output) { \ | 197 | 2.40M | size_t o = *offset; \ | 198 | 2.40M | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 2.39M | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 2.39M | return 1; \ | 201 | 2.39M | } \ | 202 | 2.40M | return 0; \ | 203 | 2.40M | } |
amqp_table.c:amqp_decode_64 Line | Count | Source | 196 | 1.03M | uint##bits##_t *output) { \ | 197 | 1.03M | size_t o = *offset; \ | 198 | 1.03M | if ((*offset = o + bits / 8) <= encoded.len) { \ | 199 | 1.03M | *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ | 200 | 1.03M | return 1; \ | 201 | 1.03M | } \ | 202 | 1.03M | return 0; \ | 203 | 1.03M | } |
Unexecuted instantiation: amqp_api.c:amqp_decode_8 Unexecuted instantiation: amqp_api.c:amqp_decode_16 Unexecuted instantiation: amqp_api.c:amqp_decode_32 Unexecuted instantiation: amqp_api.c:amqp_decode_64 Unexecuted instantiation: amqp_connection.c:amqp_decode_8 Unexecuted instantiation: amqp_connection.c:amqp_decode_16 Unexecuted instantiation: amqp_connection.c:amqp_decode_32 Unexecuted instantiation: amqp_connection.c:amqp_decode_64 Unexecuted instantiation: amqp_tcp_socket.c:amqp_decode_8 Unexecuted instantiation: amqp_tcp_socket.c:amqp_decode_16 Unexecuted instantiation: amqp_tcp_socket.c:amqp_decode_32 Unexecuted instantiation: amqp_tcp_socket.c:amqp_decode_64 Unexecuted instantiation: fuzz_server.c:amqp_decode_8 Unexecuted instantiation: fuzz_server.c:amqp_decode_16 Unexecuted instantiation: fuzz_server.c:amqp_decode_32 Unexecuted instantiation: fuzz_server.c:amqp_decode_64 Unexecuted instantiation: amqp_url.c:amqp_decode_8 Unexecuted instantiation: amqp_url.c:amqp_decode_16 Unexecuted instantiation: amqp_url.c:amqp_decode_32 Unexecuted instantiation: amqp_url.c:amqp_decode_64 |
204 | | |
205 | 7.38M | static inline int is_bigendian(void) { |
206 | 7.38M | union { |
207 | 7.38M | uint32_t i; |
208 | 7.38M | char c[4]; |
209 | 7.38M | } bint = {0x01020304}; |
210 | 7.38M | return bint.c[0] == 1; |
211 | 7.38M | } amqp_framing.c:is_bigendian Line | Count | Source | 205 | 29.5k | static inline int is_bigendian(void) { | 206 | 29.5k | union { | 207 | 29.5k | uint32_t i; | 208 | 29.5k | char c[4]; | 209 | 29.5k | } bint = {0x01020304}; | 210 | 29.5k | return bint.c[0] == 1; | 211 | 29.5k | } |
Unexecuted instantiation: amqp_mem.c:is_bigendian Unexecuted instantiation: amqp_socket.c:is_bigendian amqp_table.c:is_bigendian Line | Count | Source | 205 | 7.16M | static inline int is_bigendian(void) { | 206 | 7.16M | union { | 207 | 7.16M | uint32_t i; | 208 | 7.16M | char c[4]; | 209 | 7.16M | } bint = {0x01020304}; | 210 | 7.16M | return bint.c[0] == 1; | 211 | 7.16M | } |
Unexecuted instantiation: amqp_api.c:is_bigendian amqp_connection.c:is_bigendian Line | Count | Source | 205 | 190k | static inline int is_bigendian(void) { | 206 | 190k | union { | 207 | 190k | uint32_t i; | 208 | 190k | char c[4]; | 209 | 190k | } bint = {0x01020304}; | 210 | 190k | return bint.c[0] == 1; | 211 | 190k | } |
Unexecuted instantiation: amqp_tcp_socket.c:is_bigendian Unexecuted instantiation: fuzz_server.c:is_bigendian Unexecuted instantiation: amqp_url.c:is_bigendian |
212 | | |
213 | 11.1M | static inline void amqp_e8(uint8_t val, void *data) { |
214 | 11.1M | memcpy(data, &val, sizeof(val)); |
215 | 11.1M | } Line | Count | Source | 213 | 8.12k | static inline void amqp_e8(uint8_t val, void *data) { | 214 | 8.12k | memcpy(data, &val, sizeof(val)); | 215 | 8.12k | } |
Unexecuted instantiation: amqp_mem.c:amqp_e8 Unexecuted instantiation: amqp_socket.c:amqp_e8 Line | Count | Source | 213 | 11.1M | static inline void amqp_e8(uint8_t val, void *data) { | 214 | 11.1M | memcpy(data, &val, sizeof(val)); | 215 | 11.1M | } |
Unexecuted instantiation: amqp_api.c:amqp_e8 Unexecuted instantiation: amqp_connection.c:amqp_e8 Unexecuted instantiation: amqp_tcp_socket.c:amqp_e8 Unexecuted instantiation: fuzz_server.c:amqp_e8 Unexecuted instantiation: amqp_url.c:amqp_e8 |
216 | | |
217 | 75.7M | static inline uint8_t amqp_d8(void *data) { |
218 | 75.7M | uint8_t val; |
219 | 75.7M | memcpy(&val, data, sizeof(val)); |
220 | 75.7M | return val; |
221 | 75.7M | } Line | Count | Source | 217 | 45.9k | static inline uint8_t amqp_d8(void *data) { | 218 | 45.9k | uint8_t val; | 219 | 45.9k | memcpy(&val, data, sizeof(val)); | 220 | 45.9k | return val; | 221 | 45.9k | } |
Unexecuted instantiation: amqp_mem.c:amqp_d8 Unexecuted instantiation: amqp_socket.c:amqp_d8 Line | Count | Source | 217 | 75.5M | static inline uint8_t amqp_d8(void *data) { | 218 | 75.5M | uint8_t val; | 219 | 75.5M | memcpy(&val, data, sizeof(val)); | 220 | 75.5M | return val; | 221 | 75.5M | } |
Unexecuted instantiation: amqp_api.c:amqp_d8 amqp_connection.c:amqp_d8 Line | Count | Source | 217 | 109k | static inline uint8_t amqp_d8(void *data) { | 218 | 109k | uint8_t val; | 219 | 109k | memcpy(&val, data, sizeof(val)); | 220 | 109k | return val; | 221 | 109k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_d8 Unexecuted instantiation: fuzz_server.c:amqp_d8 Unexecuted instantiation: amqp_url.c:amqp_d8 |
222 | | |
223 | 260k | static inline void amqp_e16(uint16_t val, void *data) { |
224 | 260k | if (!is_bigendian()) { |
225 | 260k | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); |
226 | 260k | } |
227 | 260k | memcpy(data, &val, sizeof(val)); |
228 | 260k | } Line | Count | Source | 223 | 1.91k | static inline void amqp_e16(uint16_t val, void *data) { | 224 | 1.91k | if (!is_bigendian()) { | 225 | 1.91k | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); | 226 | 1.91k | } | 227 | 1.91k | memcpy(data, &val, sizeof(val)); | 228 | 1.91k | } |
Unexecuted instantiation: amqp_mem.c:amqp_e16 Unexecuted instantiation: amqp_socket.c:amqp_e16 Line | Count | Source | 223 | 258k | static inline void amqp_e16(uint16_t val, void *data) { | 224 | 258k | if (!is_bigendian()) { | 225 | 258k | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); | 226 | 258k | } | 227 | 258k | memcpy(data, &val, sizeof(val)); | 228 | 258k | } |
Unexecuted instantiation: amqp_api.c:amqp_e16 Unexecuted instantiation: amqp_connection.c:amqp_e16 Unexecuted instantiation: amqp_tcp_socket.c:amqp_e16 Unexecuted instantiation: fuzz_server.c:amqp_e16 Unexecuted instantiation: amqp_url.c:amqp_e16 |
229 | | |
230 | 2.53M | static inline uint16_t amqp_d16(void *data) { |
231 | 2.53M | uint16_t val; |
232 | 2.53M | memcpy(&val, data, sizeof(val)); |
233 | 2.53M | if (!is_bigendian()) { |
234 | 2.53M | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); |
235 | 2.53M | } |
236 | 2.53M | return val; |
237 | 2.53M | } Line | Count | Source | 230 | 17.5k | static inline uint16_t amqp_d16(void *data) { | 231 | 17.5k | uint16_t val; | 232 | 17.5k | memcpy(&val, data, sizeof(val)); | 233 | 17.5k | if (!is_bigendian()) { | 234 | 17.5k | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); | 235 | 17.5k | } | 236 | 17.5k | return val; | 237 | 17.5k | } |
Unexecuted instantiation: amqp_mem.c:amqp_d16 Unexecuted instantiation: amqp_socket.c:amqp_d16 Line | Count | Source | 230 | 2.39M | static inline uint16_t amqp_d16(void *data) { | 231 | 2.39M | uint16_t val; | 232 | 2.39M | memcpy(&val, data, sizeof(val)); | 233 | 2.39M | if (!is_bigendian()) { | 234 | 2.39M | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); | 235 | 2.39M | } | 236 | 2.39M | return val; | 237 | 2.39M | } |
Unexecuted instantiation: amqp_api.c:amqp_d16 amqp_connection.c:amqp_d16 Line | Count | Source | 230 | 114k | static inline uint16_t amqp_d16(void *data) { | 231 | 114k | uint16_t val; | 232 | 114k | memcpy(&val, data, sizeof(val)); | 233 | 114k | if (!is_bigendian()) { | 234 | 114k | val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); | 235 | 114k | } | 236 | 114k | return val; | 237 | 114k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_d16 Unexecuted instantiation: fuzz_server.c:amqp_d16 Unexecuted instantiation: amqp_url.c:amqp_d16 |
238 | | |
239 | 737k | static inline void amqp_e32(uint32_t val, void *data) { |
240 | 737k | if (!is_bigendian()) { |
241 | 737k | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | |
242 | 737k | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); |
243 | 737k | } |
244 | 737k | memcpy(data, &val, sizeof(val)); |
245 | 737k | } Line | Count | Source | 239 | 791 | static inline void amqp_e32(uint32_t val, void *data) { | 240 | 791 | if (!is_bigendian()) { | 241 | 791 | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | | 242 | 791 | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); | 243 | 791 | } | 244 | 791 | memcpy(data, &val, sizeof(val)); | 245 | 791 | } |
Unexecuted instantiation: amqp_mem.c:amqp_e32 Unexecuted instantiation: amqp_socket.c:amqp_e32 Line | Count | Source | 239 | 737k | static inline void amqp_e32(uint32_t val, void *data) { | 240 | 737k | if (!is_bigendian()) { | 241 | 737k | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | | 242 | 737k | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); | 243 | 737k | } | 244 | 737k | memcpy(data, &val, sizeof(val)); | 245 | 737k | } |
Unexecuted instantiation: amqp_api.c:amqp_e32 Unexecuted instantiation: amqp_connection.c:amqp_e32 Unexecuted instantiation: amqp_tcp_socket.c:amqp_e32 Unexecuted instantiation: fuzz_server.c:amqp_e32 Unexecuted instantiation: amqp_url.c:amqp_e32 |
246 | | |
247 | 2.60M | static inline uint32_t amqp_d32(void *data) { |
248 | 2.60M | uint32_t val; |
249 | 2.60M | memcpy(&val, data, sizeof(val)); |
250 | 2.60M | if (!is_bigendian()) { |
251 | 2.60M | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | |
252 | 2.60M | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); |
253 | 2.60M | } |
254 | 2.60M | return val; |
255 | 2.60M | } Line | Count | Source | 247 | 6.14k | static inline uint32_t amqp_d32(void *data) { | 248 | 6.14k | uint32_t val; | 249 | 6.14k | memcpy(&val, data, sizeof(val)); | 250 | 6.14k | if (!is_bigendian()) { | 251 | 6.14k | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | | 252 | 6.14k | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); | 253 | 6.14k | } | 254 | 6.14k | return val; | 255 | 6.14k | } |
Unexecuted instantiation: amqp_mem.c:amqp_d32 Unexecuted instantiation: amqp_socket.c:amqp_d32 Line | Count | Source | 247 | 2.53M | static inline uint32_t amqp_d32(void *data) { | 248 | 2.53M | uint32_t val; | 249 | 2.53M | memcpy(&val, data, sizeof(val)); | 250 | 2.53M | if (!is_bigendian()) { | 251 | 2.53M | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | | 252 | 2.53M | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); | 253 | 2.53M | } | 254 | 2.53M | return val; | 255 | 2.53M | } |
Unexecuted instantiation: amqp_api.c:amqp_d32 amqp_connection.c:amqp_d32 Line | Count | Source | 247 | 71.9k | static inline uint32_t amqp_d32(void *data) { | 248 | 71.9k | uint32_t val; | 249 | 71.9k | memcpy(&val, data, sizeof(val)); | 250 | 71.9k | if (!is_bigendian()) { | 251 | 71.9k | val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | | 252 | 71.9k | ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); | 253 | 71.9k | } | 254 | 71.9k | return val; | 255 | 71.9k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_d32 Unexecuted instantiation: fuzz_server.c:amqp_d32 Unexecuted instantiation: amqp_url.c:amqp_d32 |
256 | | |
257 | 199k | static inline void amqp_e64(uint64_t val, void *data) { |
258 | 199k | if (!is_bigendian()) { |
259 | 199k | val = ((val & 0xFF00000000000000u) >> 56u) | |
260 | 199k | ((val & 0x00FF000000000000u) >> 40u) | |
261 | 199k | ((val & 0x0000FF0000000000u) >> 24u) | |
262 | 199k | ((val & 0x000000FF00000000u) >> 8u) | |
263 | 199k | ((val & 0x00000000FF000000u) << 8u) | |
264 | 199k | ((val & 0x0000000000FF0000u) << 24u) | |
265 | 199k | ((val & 0x000000000000FF00u) << 40u) | |
266 | 199k | ((val & 0x00000000000000FFu) << 56u); |
267 | 199k | } |
268 | 199k | memcpy(data, &val, sizeof(val)); |
269 | 199k | } Line | Count | Source | 257 | 526 | static inline void amqp_e64(uint64_t val, void *data) { | 258 | 526 | if (!is_bigendian()) { | 259 | 526 | val = ((val & 0xFF00000000000000u) >> 56u) | | 260 | 526 | ((val & 0x00FF000000000000u) >> 40u) | | 261 | 526 | ((val & 0x0000FF0000000000u) >> 24u) | | 262 | 526 | ((val & 0x000000FF00000000u) >> 8u) | | 263 | 526 | ((val & 0x00000000FF000000u) << 8u) | | 264 | 526 | ((val & 0x0000000000FF0000u) << 24u) | | 265 | 526 | ((val & 0x000000000000FF00u) << 40u) | | 266 | 526 | ((val & 0x00000000000000FFu) << 56u); | 267 | 526 | } | 268 | 526 | memcpy(data, &val, sizeof(val)); | 269 | 526 | } |
Unexecuted instantiation: amqp_mem.c:amqp_e64 Unexecuted instantiation: amqp_socket.c:amqp_e64 Line | Count | Source | 257 | 198k | static inline void amqp_e64(uint64_t val, void *data) { | 258 | 198k | if (!is_bigendian()) { | 259 | 198k | val = ((val & 0xFF00000000000000u) >> 56u) | | 260 | 198k | ((val & 0x00FF000000000000u) >> 40u) | | 261 | 198k | ((val & 0x0000FF0000000000u) >> 24u) | | 262 | 198k | ((val & 0x000000FF00000000u) >> 8u) | | 263 | 198k | ((val & 0x00000000FF000000u) << 8u) | | 264 | 198k | ((val & 0x0000000000FF0000u) << 24u) | | 265 | 198k | ((val & 0x000000000000FF00u) << 40u) | | 266 | 198k | ((val & 0x00000000000000FFu) << 56u); | 267 | 198k | } | 268 | 198k | memcpy(data, &val, sizeof(val)); | 269 | 198k | } |
Unexecuted instantiation: amqp_api.c:amqp_e64 Unexecuted instantiation: amqp_connection.c:amqp_e64 Unexecuted instantiation: amqp_tcp_socket.c:amqp_e64 Unexecuted instantiation: fuzz_server.c:amqp_e64 Unexecuted instantiation: amqp_url.c:amqp_e64 |
270 | | |
271 | 1.04M | static inline uint64_t amqp_d64(void *data) { |
272 | 1.04M | uint64_t val; |
273 | 1.04M | memcpy(&val, data, sizeof(val)); |
274 | 1.04M | if (!is_bigendian()) { |
275 | 1.04M | val = ((val & 0xFF00000000000000u) >> 56u) | |
276 | 1.04M | ((val & 0x00FF000000000000u) >> 40u) | |
277 | 1.04M | ((val & 0x0000FF0000000000u) >> 24u) | |
278 | 1.04M | ((val & 0x000000FF00000000u) >> 8u) | |
279 | 1.04M | ((val & 0x00000000FF000000u) << 8u) | |
280 | 1.04M | ((val & 0x0000000000FF0000u) << 24u) | |
281 | 1.04M | ((val & 0x000000000000FF00u) << 40u) | |
282 | 1.04M | ((val & 0x00000000000000FFu) << 56u); |
283 | 1.04M | } |
284 | 1.04M | return val; |
285 | 1.04M | } Line | Count | Source | 271 | 2.57k | static inline uint64_t amqp_d64(void *data) { | 272 | 2.57k | uint64_t val; | 273 | 2.57k | memcpy(&val, data, sizeof(val)); | 274 | 2.57k | if (!is_bigendian()) { | 275 | 2.57k | val = ((val & 0xFF00000000000000u) >> 56u) | | 276 | 2.57k | ((val & 0x00FF000000000000u) >> 40u) | | 277 | 2.57k | ((val & 0x0000FF0000000000u) >> 24u) | | 278 | 2.57k | ((val & 0x000000FF00000000u) >> 8u) | | 279 | 2.57k | ((val & 0x00000000FF000000u) << 8u) | | 280 | 2.57k | ((val & 0x0000000000FF0000u) << 24u) | | 281 | 2.57k | ((val & 0x000000000000FF00u) << 40u) | | 282 | 2.57k | ((val & 0x00000000000000FFu) << 56u); | 283 | 2.57k | } | 284 | 2.57k | return val; | 285 | 2.57k | } |
Unexecuted instantiation: amqp_mem.c:amqp_d64 Unexecuted instantiation: amqp_socket.c:amqp_d64 Line | Count | Source | 271 | 1.03M | static inline uint64_t amqp_d64(void *data) { | 272 | 1.03M | uint64_t val; | 273 | 1.03M | memcpy(&val, data, sizeof(val)); | 274 | 1.03M | if (!is_bigendian()) { | 275 | 1.03M | val = ((val & 0xFF00000000000000u) >> 56u) | | 276 | 1.03M | ((val & 0x00FF000000000000u) >> 40u) | | 277 | 1.03M | ((val & 0x0000FF0000000000u) >> 24u) | | 278 | 1.03M | ((val & 0x000000FF00000000u) >> 8u) | | 279 | 1.03M | ((val & 0x00000000FF000000u) << 8u) | | 280 | 1.03M | ((val & 0x0000000000FF0000u) << 24u) | | 281 | 1.03M | ((val & 0x000000000000FF00u) << 40u) | | 282 | 1.03M | ((val & 0x00000000000000FFu) << 56u); | 283 | 1.03M | } | 284 | 1.03M | return val; | 285 | 1.03M | } |
Unexecuted instantiation: amqp_api.c:amqp_d64 amqp_connection.c:amqp_d64 Line | Count | Source | 271 | 4.60k | static inline uint64_t amqp_d64(void *data) { | 272 | 4.60k | uint64_t val; | 273 | 4.60k | memcpy(&val, data, sizeof(val)); | 274 | 4.60k | if (!is_bigendian()) { | 275 | 4.60k | val = ((val & 0xFF00000000000000u) >> 56u) | | 276 | 4.60k | ((val & 0x00FF000000000000u) >> 40u) | | 277 | 4.60k | ((val & 0x0000FF0000000000u) >> 24u) | | 278 | 4.60k | ((val & 0x000000FF00000000u) >> 8u) | | 279 | 4.60k | ((val & 0x00000000FF000000u) << 8u) | | 280 | 4.60k | ((val & 0x0000000000FF0000u) << 24u) | | 281 | 4.60k | ((val & 0x000000000000FF00u) << 40u) | | 282 | 4.60k | ((val & 0x00000000000000FFu) << 56u); | 283 | 4.60k | } | 284 | 4.60k | return val; | 285 | 4.60k | } |
Unexecuted instantiation: amqp_tcp_socket.c:amqp_d64 Unexecuted instantiation: fuzz_server.c:amqp_d64 Unexecuted instantiation: amqp_url.c:amqp_d64 |
286 | | |
287 | | DECLARE_CODEC_BASE_TYPE(8) |
288 | | DECLARE_CODEC_BASE_TYPE(16) |
289 | | DECLARE_CODEC_BASE_TYPE(32) |
290 | | DECLARE_CODEC_BASE_TYPE(64) |
291 | | |
292 | | static inline int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset, |
293 | 59.8k | amqp_bytes_t input) { |
294 | 59.8k | size_t o = *offset; |
295 | | /* The memcpy below has undefined behavior if the input is NULL. It is valid |
296 | | * for a 0-length amqp_bytes_t to have .bytes == NULL. Thus we should check |
297 | | * before encoding. |
298 | | */ |
299 | 59.8k | if (input.len == 0) { |
300 | 33.5k | return 1; |
301 | 33.5k | } |
302 | 26.2k | *offset = o + input.len; |
303 | | /* Compare against remaining space rather than o + input.len to avoid size_t |
304 | | * overflow; o <= encoded.len, so encoded.len - o cannot underflow. */ |
305 | 26.2k | if (o <= encoded.len && input.len <= encoded.len - o) { |
306 | 26.2k | memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len); |
307 | 26.2k | return 1; |
308 | 26.2k | } else { |
309 | 0 | return 0; |
310 | 0 | } |
311 | 26.2k | } amqp_framing.c:amqp_encode_bytes Line | Count | Source | 293 | 6.63k | amqp_bytes_t input) { | 294 | 6.63k | size_t o = *offset; | 295 | | /* The memcpy below has undefined behavior if the input is NULL. It is valid | 296 | | * for a 0-length amqp_bytes_t to have .bytes == NULL. Thus we should check | 297 | | * before encoding. | 298 | | */ | 299 | 6.63k | if (input.len == 0) { | 300 | 2.67k | return 1; | 301 | 2.67k | } | 302 | 3.96k | *offset = o + input.len; | 303 | | /* Compare against remaining space rather than o + input.len to avoid size_t | 304 | | * overflow; o <= encoded.len, so encoded.len - o cannot underflow. */ | 305 | 3.96k | if (o <= encoded.len && input.len <= encoded.len - o) { | 306 | 3.96k | memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len); | 307 | 3.96k | return 1; | 308 | 3.96k | } else { | 309 | 0 | return 0; | 310 | 0 | } | 311 | 3.96k | } |
Unexecuted instantiation: amqp_mem.c:amqp_encode_bytes Unexecuted instantiation: amqp_socket.c:amqp_encode_bytes amqp_table.c:amqp_encode_bytes Line | Count | Source | 293 | 53.1k | amqp_bytes_t input) { | 294 | 53.1k | size_t o = *offset; | 295 | | /* The memcpy below has undefined behavior if the input is NULL. It is valid | 296 | | * for a 0-length amqp_bytes_t to have .bytes == NULL. Thus we should check | 297 | | * before encoding. | 298 | | */ | 299 | 53.1k | if (input.len == 0) { | 300 | 30.8k | return 1; | 301 | 30.8k | } | 302 | 22.2k | *offset = o + input.len; | 303 | | /* Compare against remaining space rather than o + input.len to avoid size_t | 304 | | * overflow; o <= encoded.len, so encoded.len - o cannot underflow. */ | 305 | 22.2k | if (o <= encoded.len && input.len <= encoded.len - o) { | 306 | 22.2k | memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len); | 307 | 22.2k | return 1; | 308 | 22.2k | } else { | 309 | 0 | return 0; | 310 | 0 | } | 311 | 22.2k | } |
Unexecuted instantiation: amqp_api.c:amqp_encode_bytes Unexecuted instantiation: amqp_connection.c:amqp_encode_bytes Unexecuted instantiation: amqp_tcp_socket.c:amqp_encode_bytes Unexecuted instantiation: fuzz_server.c:amqp_encode_bytes Unexecuted instantiation: amqp_url.c:amqp_encode_bytes |
312 | | |
313 | | static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset, |
314 | 1.14M | amqp_bytes_t *output, size_t len) { |
315 | 1.14M | size_t o = *offset; |
316 | 1.14M | *offset = o + len; |
317 | | /* Compare against remaining space rather than o + len: with len read from the |
318 | | * wire (uint32_t), o + len can overflow size_t on 32-bit platforms and wrap |
319 | | * past the check, yielding an out-of-bounds amqp_bytes_t. o <= encoded.len, |
320 | | * so encoded.len - o cannot underflow. */ |
321 | 1.14M | if (o <= encoded.len && len <= encoded.len - o) { |
322 | 1.14M | output->bytes = amqp_offset(encoded.bytes, o); |
323 | 1.14M | output->len = len; |
324 | 1.14M | return 1; |
325 | 1.14M | } else { |
326 | 4.09k | return 0; |
327 | 4.09k | } |
328 | 1.14M | } amqp_framing.c:amqp_decode_bytes Line | Count | Source | 314 | 36.5k | amqp_bytes_t *output, size_t len) { | 315 | 36.5k | size_t o = *offset; | 316 | 36.5k | *offset = o + len; | 317 | | /* Compare against remaining space rather than o + len: with len read from the | 318 | | * wire (uint32_t), o + len can overflow size_t on 32-bit platforms and wrap | 319 | | * past the check, yielding an out-of-bounds amqp_bytes_t. o <= encoded.len, | 320 | | * so encoded.len - o cannot underflow. */ | 321 | 36.5k | if (o <= encoded.len && len <= encoded.len - o) { | 322 | 32.9k | output->bytes = amqp_offset(encoded.bytes, o); | 323 | 32.9k | output->len = len; | 324 | 32.9k | return 1; | 325 | 32.9k | } else { | 326 | 3.65k | return 0; | 327 | 3.65k | } | 328 | 36.5k | } |
Unexecuted instantiation: amqp_mem.c:amqp_decode_bytes Unexecuted instantiation: amqp_socket.c:amqp_decode_bytes amqp_table.c:amqp_decode_bytes Line | Count | Source | 314 | 1.11M | amqp_bytes_t *output, size_t len) { | 315 | 1.11M | size_t o = *offset; | 316 | 1.11M | *offset = o + len; | 317 | | /* Compare against remaining space rather than o + len: with len read from the | 318 | | * wire (uint32_t), o + len can overflow size_t on 32-bit platforms and wrap | 319 | | * past the check, yielding an out-of-bounds amqp_bytes_t. o <= encoded.len, | 320 | | * so encoded.len - o cannot underflow. */ | 321 | 1.11M | if (o <= encoded.len && len <= encoded.len - o) { | 322 | 1.10M | output->bytes = amqp_offset(encoded.bytes, o); | 323 | 1.10M | output->len = len; | 324 | 1.10M | return 1; | 325 | 1.10M | } else { | 326 | 445 | return 0; | 327 | 445 | } | 328 | 1.11M | } |
Unexecuted instantiation: amqp_api.c:amqp_decode_bytes Unexecuted instantiation: amqp_connection.c:amqp_decode_bytes Unexecuted instantiation: amqp_tcp_socket.c:amqp_decode_bytes Unexecuted instantiation: fuzz_server.c:amqp_decode_bytes Unexecuted instantiation: amqp_url.c:amqp_decode_bytes |
329 | | |
330 | | AMQP_NORETURN |
331 | | void amqp_abort(const char *fmt, ...); |
332 | | |
333 | | int amqp_bytes_equal(amqp_bytes_t r, amqp_bytes_t l); |
334 | | |
335 | 44 | static inline amqp_rpc_reply_t amqp_rpc_reply_error(amqp_status_enum status) { |
336 | 44 | amqp_rpc_reply_t reply; |
337 | 44 | reply.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; |
338 | 44 | reply.library_error = status; |
339 | 44 | return reply; |
340 | 44 | } Unexecuted instantiation: amqp_framing.c:amqp_rpc_reply_error Unexecuted instantiation: amqp_mem.c:amqp_rpc_reply_error amqp_socket.c:amqp_rpc_reply_error Line | Count | Source | 335 | 44 | static inline amqp_rpc_reply_t amqp_rpc_reply_error(amqp_status_enum status) { | 336 | 44 | amqp_rpc_reply_t reply; | 337 | 44 | reply.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; | 338 | 44 | reply.library_error = status; | 339 | 44 | return reply; | 340 | 44 | } |
Unexecuted instantiation: amqp_table.c:amqp_rpc_reply_error Unexecuted instantiation: amqp_api.c:amqp_rpc_reply_error Unexecuted instantiation: amqp_connection.c:amqp_rpc_reply_error Unexecuted instantiation: amqp_tcp_socket.c:amqp_rpc_reply_error Unexecuted instantiation: fuzz_server.c:amqp_rpc_reply_error Unexecuted instantiation: amqp_url.c:amqp_rpc_reply_error |
341 | | |
342 | | int amqp_send_frame_inner(amqp_connection_state_t state, |
343 | | const amqp_frame_t *frame, int flags, |
344 | | amqp_time_t deadline); |
345 | | #endif |