Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2000-2012 Free Software Foundation, Inc. |
3 | | * Copyright (C) 2016-2017 Red Hat, Inc. |
4 | | * |
5 | | * Author: Nikos Mavrogiannopoulos |
6 | | * |
7 | | * This file is part of GnuTLS. |
8 | | * |
9 | | * The GnuTLS is free software; you can redistribute it and/or |
10 | | * modify it under the terms of the GNU Lesser General Public License |
11 | | * as published by the Free Software Foundation; either version 2.1 of |
12 | | * the License, or (at your option) any later version. |
13 | | * |
14 | | * This library is distributed in the hope that it will be useful, but |
15 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | | * Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
21 | | * |
22 | | */ |
23 | | |
24 | | #ifndef GNUTLS_LIB_STR_H |
25 | | #define GNUTLS_LIB_STR_H |
26 | | |
27 | | #include "config.h" |
28 | | #include "gnutls_int.h" |
29 | | #include "errors.h" |
30 | | #include "datum.h" |
31 | | #include <c-ctype.h> |
32 | | #include "errors.h" |
33 | | |
34 | | #ifdef HAVE_DCGETTEXT |
35 | | #include "gettext.h" |
36 | 0 | #define _(String) dgettext(PACKAGE, String) |
37 | | #define N_(String) gettext_noop(String) |
38 | | #else |
39 | | #define _(String) String |
40 | | #define N_(String) String |
41 | | #endif |
42 | | |
43 | | int gnutls_utf8_password_normalize(const uint8_t *password, |
44 | | unsigned password_len, gnutls_datum_t *out, |
45 | | unsigned flags); |
46 | | |
47 | | #define _gnutls_utf8_password_normalize(p, plen, out, ignore_errs) \ |
48 | 0 | gnutls_utf8_password_normalize( \ |
49 | 0 | (unsigned char *)p, plen, out, \ |
50 | 0 | ignore_errs ? (GNUTLS_UTF8_IGNORE_ERRS) : 0) |
51 | | |
52 | | int _gnutls_idna_email_map(const char *input, unsigned ilen, |
53 | | gnutls_datum_t *output); |
54 | | int _gnutls_idna_email_reverse_map(const char *input, unsigned ilen, |
55 | | gnutls_datum_t *output); |
56 | | |
57 | | inline static unsigned _gnutls_str_is_print(const char *str, unsigned size) |
58 | 0 | { |
59 | 0 | unsigned i; |
60 | 0 | for (i = 0; i < size; i++) { |
61 | 0 | if (!c_isprint(str[i])) |
62 | 0 | return 0; |
63 | 0 | } |
64 | 0 | return 1; |
65 | 0 | } Unexecuted instantiation: ocsp.c:_gnutls_str_is_print Unexecuted instantiation: output.c:_gnutls_str_is_print Unexecuted instantiation: time.c:_gnutls_str_is_print Unexecuted instantiation: tls_features.c:_gnutls_str_is_print Unexecuted instantiation: verify-high.c:_gnutls_str_is_print Unexecuted instantiation: verify.c:_gnutls_str_is_print Unexecuted instantiation: virt-san.c:_gnutls_str_is_print Unexecuted instantiation: x509.c:_gnutls_str_is_print Unexecuted instantiation: x509_ext.c:_gnutls_str_is_print Unexecuted instantiation: common.c:_gnutls_str_is_print Unexecuted instantiation: crl.c:_gnutls_str_is_print Unexecuted instantiation: crq.c:_gnutls_str_is_print Unexecuted instantiation: dn.c:_gnutls_str_is_print Unexecuted instantiation: email-verify.c:_gnutls_str_is_print Unexecuted instantiation: extensions.c:_gnutls_str_is_print Unexecuted instantiation: hostname-verify.c:_gnutls_str_is_print Unexecuted instantiation: ip.c:_gnutls_str_is_print Unexecuted instantiation: key_decode.c:_gnutls_str_is_print Unexecuted instantiation: key_encode.c:_gnutls_str_is_print Unexecuted instantiation: krb5.c:_gnutls_str_is_print Unexecuted instantiation: name_constraints.c:_gnutls_str_is_print Unexecuted instantiation: pkcs12.c:_gnutls_str_is_print Unexecuted instantiation: pkcs12_bag.c:_gnutls_str_is_print Unexecuted instantiation: pkcs12_encr.c:_gnutls_str_is_print Unexecuted instantiation: pkcs7-crypt.c:_gnutls_str_is_print Unexecuted instantiation: privkey_openssl.c:_gnutls_str_is_print Unexecuted instantiation: privkey_pkcs8.c:_gnutls_str_is_print Unexecuted instantiation: privkey_pkcs8_pbes1.c:_gnutls_str_is_print Unexecuted instantiation: prov-seed.c:_gnutls_str_is_print Unexecuted instantiation: verify-high2.c:_gnutls_str_is_print Unexecuted instantiation: x509_dn.c:_gnutls_str_is_print Unexecuted instantiation: x509_write.c:_gnutls_str_is_print Unexecuted instantiation: attributes.c:_gnutls_str_is_print |
66 | | |
67 | | inline static unsigned _gnutls_dnsname_is_valid(const char *str, unsigned size) |
68 | 0 | { |
69 | 0 | unsigned i; |
70 | 0 | for (i = 0; i < size; i++) { |
71 | 0 | if (!(c_isalnum(str[i]) || str[i] == '-' || str[i] == '.')) |
72 | 0 | return 0; |
73 | 0 | } |
74 | 0 | return 1; |
75 | 0 | } Unexecuted instantiation: ocsp.c:_gnutls_dnsname_is_valid Unexecuted instantiation: output.c:_gnutls_dnsname_is_valid Unexecuted instantiation: time.c:_gnutls_dnsname_is_valid Unexecuted instantiation: tls_features.c:_gnutls_dnsname_is_valid Unexecuted instantiation: verify-high.c:_gnutls_dnsname_is_valid Unexecuted instantiation: verify.c:_gnutls_dnsname_is_valid Unexecuted instantiation: virt-san.c:_gnutls_dnsname_is_valid Unexecuted instantiation: x509.c:_gnutls_dnsname_is_valid Unexecuted instantiation: x509_ext.c:_gnutls_dnsname_is_valid Unexecuted instantiation: common.c:_gnutls_dnsname_is_valid Unexecuted instantiation: crl.c:_gnutls_dnsname_is_valid Unexecuted instantiation: crq.c:_gnutls_dnsname_is_valid Unexecuted instantiation: dn.c:_gnutls_dnsname_is_valid Unexecuted instantiation: email-verify.c:_gnutls_dnsname_is_valid Unexecuted instantiation: extensions.c:_gnutls_dnsname_is_valid Unexecuted instantiation: hostname-verify.c:_gnutls_dnsname_is_valid Unexecuted instantiation: ip.c:_gnutls_dnsname_is_valid Unexecuted instantiation: key_decode.c:_gnutls_dnsname_is_valid Unexecuted instantiation: key_encode.c:_gnutls_dnsname_is_valid Unexecuted instantiation: krb5.c:_gnutls_dnsname_is_valid Unexecuted instantiation: name_constraints.c:_gnutls_dnsname_is_valid Unexecuted instantiation: pkcs12.c:_gnutls_dnsname_is_valid Unexecuted instantiation: pkcs12_bag.c:_gnutls_dnsname_is_valid Unexecuted instantiation: pkcs12_encr.c:_gnutls_dnsname_is_valid Unexecuted instantiation: pkcs7-crypt.c:_gnutls_dnsname_is_valid Unexecuted instantiation: privkey_openssl.c:_gnutls_dnsname_is_valid Unexecuted instantiation: privkey_pkcs8.c:_gnutls_dnsname_is_valid Unexecuted instantiation: privkey_pkcs8_pbes1.c:_gnutls_dnsname_is_valid Unexecuted instantiation: prov-seed.c:_gnutls_dnsname_is_valid Unexecuted instantiation: verify-high2.c:_gnutls_dnsname_is_valid Unexecuted instantiation: x509_dn.c:_gnutls_dnsname_is_valid Unexecuted instantiation: x509_write.c:_gnutls_dnsname_is_valid Unexecuted instantiation: attributes.c:_gnutls_dnsname_is_valid |
76 | | |
77 | | void _gnutls_str_cpy(char *dest, size_t dest_tot_size, const char *src); |
78 | | void _gnutls_str_cat(char *dest, size_t dest_tot_size, const char *src); |
79 | | |
80 | | typedef struct gnutls_buffer_st { |
81 | | uint8_t *allocd; /* pointer to allocated data */ |
82 | | uint8_t *data; /* API: pointer to data to copy from */ |
83 | | size_t max_length; |
84 | | size_t length; /* API: current length */ |
85 | | } gnutls_buffer_st; |
86 | | |
87 | | /* Initialize a buffer */ |
88 | | void _gnutls_buffer_init(gnutls_buffer_st *); |
89 | | |
90 | | /* Free the data in a buffer */ |
91 | | void _gnutls_buffer_clear(gnutls_buffer_st *); |
92 | | |
93 | | /* Set the buffer data to be of zero length */ |
94 | | inline static void _gnutls_buffer_reset(gnutls_buffer_st *buf) |
95 | 0 | { |
96 | 0 | buf->data = buf->allocd; |
97 | 0 | buf->length = 0; |
98 | 0 | } Unexecuted instantiation: ocsp.c:_gnutls_buffer_reset Unexecuted instantiation: output.c:_gnutls_buffer_reset Unexecuted instantiation: time.c:_gnutls_buffer_reset Unexecuted instantiation: tls_features.c:_gnutls_buffer_reset Unexecuted instantiation: verify-high.c:_gnutls_buffer_reset Unexecuted instantiation: verify.c:_gnutls_buffer_reset Unexecuted instantiation: virt-san.c:_gnutls_buffer_reset Unexecuted instantiation: x509.c:_gnutls_buffer_reset Unexecuted instantiation: x509_ext.c:_gnutls_buffer_reset Unexecuted instantiation: common.c:_gnutls_buffer_reset Unexecuted instantiation: crl.c:_gnutls_buffer_reset Unexecuted instantiation: crq.c:_gnutls_buffer_reset Unexecuted instantiation: dn.c:_gnutls_buffer_reset Unexecuted instantiation: email-verify.c:_gnutls_buffer_reset Unexecuted instantiation: extensions.c:_gnutls_buffer_reset Unexecuted instantiation: hostname-verify.c:_gnutls_buffer_reset Unexecuted instantiation: ip.c:_gnutls_buffer_reset Unexecuted instantiation: key_decode.c:_gnutls_buffer_reset Unexecuted instantiation: key_encode.c:_gnutls_buffer_reset Unexecuted instantiation: krb5.c:_gnutls_buffer_reset Unexecuted instantiation: name_constraints.c:_gnutls_buffer_reset Unexecuted instantiation: pkcs12.c:_gnutls_buffer_reset Unexecuted instantiation: pkcs12_bag.c:_gnutls_buffer_reset Unexecuted instantiation: pkcs12_encr.c:_gnutls_buffer_reset Unexecuted instantiation: pkcs7-crypt.c:_gnutls_buffer_reset Unexecuted instantiation: privkey_openssl.c:_gnutls_buffer_reset Unexecuted instantiation: privkey_pkcs8.c:_gnutls_buffer_reset Unexecuted instantiation: privkey_pkcs8_pbes1.c:_gnutls_buffer_reset Unexecuted instantiation: prov-seed.c:_gnutls_buffer_reset Unexecuted instantiation: verify-high2.c:_gnutls_buffer_reset Unexecuted instantiation: x509_dn.c:_gnutls_buffer_reset Unexecuted instantiation: x509_write.c:_gnutls_buffer_reset Unexecuted instantiation: attributes.c:_gnutls_buffer_reset |
99 | | |
100 | | int _gnutls_buffer_resize(gnutls_buffer_st *, size_t new_size); |
101 | | |
102 | | int _gnutls_buffer_append_str(gnutls_buffer_st *, const char *str); |
103 | | |
104 | 0 | #define _gnutls_buffer_append_data gnutls_buffer_append_data |
105 | | |
106 | | #include "num.h" |
107 | | |
108 | | int _gnutls_buffer_append_prefix(gnutls_buffer_st *buf, int pfx_size, |
109 | | size_t data_size); |
110 | | |
111 | | int _gnutls_buffer_append_mpi(gnutls_buffer_st *buf, int pfx_size, bigint_t, |
112 | | int lz); |
113 | | |
114 | | int _gnutls_buffer_append_fixed_mpi(gnutls_buffer_st *buf, bigint_t mpi, |
115 | | unsigned size); |
116 | | |
117 | | int _gnutls_buffer_append_data_prefix(gnutls_buffer_st *buf, int pfx_size, |
118 | | const void *data, size_t data_size); |
119 | | int _gnutls_buffer_pop_data(gnutls_buffer_st *, void *, size_t size); |
120 | | void _gnutls_buffer_pop_datum(gnutls_buffer_st *, gnutls_datum_t *, |
121 | | size_t max_size); |
122 | | |
123 | | /* 32-bit prefix */ |
124 | | int _gnutls_buffer_pop_prefix32(gnutls_buffer_st *buf, size_t *data_size, |
125 | | int check); |
126 | | int _gnutls_buffer_pop_prefix24(gnutls_buffer_st *buf, size_t *data_size, |
127 | | int check); |
128 | | int _gnutls_buffer_pop_prefix16(gnutls_buffer_st *buf, size_t *data_size, |
129 | | int check); |
130 | | int _gnutls_buffer_pop_prefix8(gnutls_buffer_st *, uint8_t *, int check); |
131 | | |
132 | | /* 32-bit prefix */ |
133 | | int _gnutls_buffer_pop_datum_prefix32(gnutls_buffer_st *buf, |
134 | | gnutls_datum_t *data); |
135 | | |
136 | | /* 24-bit prefix */ |
137 | | int _gnutls_buffer_pop_datum_prefix24(gnutls_buffer_st *buf, |
138 | | gnutls_datum_t *data); |
139 | | |
140 | | /* 16-bit prefix */ |
141 | | int _gnutls_buffer_pop_datum_prefix16(gnutls_buffer_st *buf, |
142 | | gnutls_datum_t *data); |
143 | | |
144 | | /* 8-bit prefix */ |
145 | | int _gnutls_buffer_pop_datum_prefix8(gnutls_buffer_st *buf, |
146 | | gnutls_datum_t *data); |
147 | | |
148 | | int _gnutls_buffer_to_datum(gnutls_buffer_st *str, gnutls_datum_t *data, |
149 | | unsigned is_str); |
150 | | |
151 | | inline static void _gnutls_ro_buffer_from_datum(gnutls_buffer_st *str, |
152 | | gnutls_datum_t *data) |
153 | 0 | { |
154 | 0 | _gnutls_buffer_init(str); |
155 | 0 | str->length = data->size; |
156 | 0 | str->max_length = data->size; |
157 | 0 | str->data = data->data; |
158 | 0 | } Unexecuted instantiation: ocsp.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: output.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: time.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: tls_features.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: verify-high.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: verify.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: virt-san.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: x509.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: x509_ext.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: common.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: crl.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: crq.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: dn.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: email-verify.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: extensions.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: hostname-verify.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: ip.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: key_decode.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: key_encode.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: krb5.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: name_constraints.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: pkcs12.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: pkcs12_bag.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: pkcs12_encr.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: pkcs7-crypt.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: privkey_openssl.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: privkey_pkcs8.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: privkey_pkcs8_pbes1.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: prov-seed.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: verify-high2.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: x509_dn.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: x509_write.c:_gnutls_ro_buffer_from_datum Unexecuted instantiation: attributes.c:_gnutls_ro_buffer_from_datum |
159 | | |
160 | | int _gnutls_buffer_append_escape(gnutls_buffer_st *dest, const void *data, |
161 | | size_t data_size, const char *invalid_chars); |
162 | | int _gnutls_buffer_unescape(gnutls_buffer_st *dest); |
163 | | |
164 | | #ifndef __attribute__ |
165 | | /* This feature is available in gcc versions 2.5 and later. */ |
166 | | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) |
167 | | #define __attribute__(Spec) /* empty */ |
168 | | #endif |
169 | | #endif |
170 | | |
171 | | int _gnutls_buffer_append_printf(gnutls_buffer_st *dest, const char *fmt, ...) |
172 | | __attribute__((format(printf, 2, 3))); |
173 | | |
174 | | void _gnutls_buffer_hexprint(gnutls_buffer_st *str, const void *data, |
175 | | size_t len); |
176 | | int _gnutls_buffer_base64print(gnutls_buffer_st *str, const void *data, |
177 | | size_t len); |
178 | | void _gnutls_buffer_hexdump(gnutls_buffer_st *str, const void *data, size_t len, |
179 | | const char *spc); |
180 | | void _gnutls_buffer_asciiprint(gnutls_buffer_st *str, const char *data, |
181 | | size_t len); |
182 | | |
183 | | char *_gnutls_bin2hex(const void *old, size_t oldlen, char *buffer, |
184 | | size_t buffer_size, const char *separator); |
185 | | int _gnutls_hex2bin(const char *hex_data, size_t hex_size, uint8_t *bin_data, |
186 | | size_t *bin_size); |
187 | | |
188 | | int _gnutls_hostname_compare(const char *certname, size_t certnamesize, |
189 | | const char *hostname, unsigned vflags); |
190 | | |
191 | | #define MAX_CN 256 |
192 | | #define MAX_DN 1024 |
193 | | |
194 | | #define BUFFER_APPEND(b, x, s) \ |
195 | | { \ |
196 | | ret = _gnutls_buffer_append_data(b, x, s); \ |
197 | | if (ret < 0) { \ |
198 | | gnutls_assert(); \ |
199 | | return ret; \ |
200 | | } \ |
201 | | } |
202 | | |
203 | | /* append data prefixed with 4-bytes length field*/ |
204 | | #define BUFFER_APPEND_PFX4(b, x, s) \ |
205 | | { \ |
206 | | ret = _gnutls_buffer_append_data_prefix(b, 32, x, s); \ |
207 | | if (ret < 0) { \ |
208 | | gnutls_assert(); \ |
209 | | return ret; \ |
210 | | } \ |
211 | | } |
212 | | |
213 | | #define BUFFER_APPEND_PFX3(b, x, s) \ |
214 | | { \ |
215 | | ret = _gnutls_buffer_append_data_prefix(b, 24, x, s); \ |
216 | | if (ret < 0) { \ |
217 | | gnutls_assert(); \ |
218 | | return ret; \ |
219 | | } \ |
220 | | } |
221 | | |
222 | | #define BUFFER_APPEND_PFX2(b, x, s) \ |
223 | | { \ |
224 | | ret = _gnutls_buffer_append_data_prefix(b, 16, x, s); \ |
225 | | if (ret < 0) { \ |
226 | | gnutls_assert(); \ |
227 | | return ret; \ |
228 | | } \ |
229 | | } |
230 | | |
231 | | #define BUFFER_APPEND_PFX1(b, x, s) \ |
232 | | { \ |
233 | | ret = _gnutls_buffer_append_data_prefix(b, 8, x, s); \ |
234 | | if (ret < 0) { \ |
235 | | gnutls_assert(); \ |
236 | | return ret; \ |
237 | | } \ |
238 | | } |
239 | | |
240 | | #define BUFFER_APPEND_NUM(b, s) \ |
241 | | { \ |
242 | | ret = _gnutls_buffer_append_prefix(b, 32, s); \ |
243 | | if (ret < 0) { \ |
244 | | gnutls_assert(); \ |
245 | | return ret; \ |
246 | | } \ |
247 | | } |
248 | | |
249 | | #define BUFFER_APPEND_TS(b, s) \ |
250 | | { \ |
251 | | ret = _gnutls_buffer_append_prefix(b, 32, \ |
252 | | (uint64_t)s.tv_sec >> 32); \ |
253 | | if (ret < 0) { \ |
254 | | gnutls_assert(); \ |
255 | | return ret; \ |
256 | | } \ |
257 | | ret = _gnutls_buffer_append_prefix(b, 32, \ |
258 | | s.tv_sec & 0xFFFFFFFF); \ |
259 | | if (ret < 0) { \ |
260 | | gnutls_assert(); \ |
261 | | return ret; \ |
262 | | } \ |
263 | | ret = _gnutls_buffer_append_prefix(b, 32, s.tv_nsec); \ |
264 | | if (ret < 0) { \ |
265 | | gnutls_assert(); \ |
266 | | return ret; \ |
267 | | } \ |
268 | | } |
269 | | |
270 | | #define BUFFER_POP(b, x, s) \ |
271 | | { \ |
272 | | ret = _gnutls_buffer_pop_data(b, x, s); \ |
273 | | if (ret < 0) { \ |
274 | | ret = GNUTLS_E_PARSING_ERROR; \ |
275 | | gnutls_assert(); \ |
276 | | goto error; \ |
277 | | } \ |
278 | | } |
279 | | |
280 | | #define BUFFER_POP_DATUM(b, o) \ |
281 | | { \ |
282 | | gnutls_datum_t d; \ |
283 | | ret = _gnutls_buffer_pop_datum_prefix32(b, &d); \ |
284 | | if (ret >= 0) \ |
285 | | ret = _gnutls_set_datum(o, d.data, d.size); \ |
286 | | if (ret < 0) { \ |
287 | | gnutls_assert(); \ |
288 | | goto error; \ |
289 | | } \ |
290 | | } |
291 | | |
292 | | #define BUFFER_POP_NUM(b, o) \ |
293 | | { \ |
294 | | size_t s; \ |
295 | | ret = _gnutls_buffer_pop_prefix32(b, &s, 0); \ |
296 | | if (ret < 0) { \ |
297 | | gnutls_assert(); \ |
298 | | goto error; \ |
299 | | } \ |
300 | | o = s; \ |
301 | | } |
302 | | |
303 | | #define BUFFER_POP_CAST_NUM(b, o) \ |
304 | | { \ |
305 | | size_t s; \ |
306 | | ret = _gnutls_buffer_pop_prefix32(b, &s, 0); \ |
307 | | if (ret < 0) { \ |
308 | | gnutls_assert(); \ |
309 | | goto error; \ |
310 | | } \ |
311 | | o = (void *)(intptr_t)(s); \ |
312 | | } |
313 | | |
314 | | #define BUFFER_POP_TS(b, o) \ |
315 | | { \ |
316 | | size_t s; \ |
317 | | uint64_t v; \ |
318 | | ret = _gnutls_buffer_pop_prefix32(b, &s, 0); \ |
319 | | if (ret < 0) { \ |
320 | | gnutls_assert(); \ |
321 | | goto error; \ |
322 | | } \ |
323 | | v = s; \ |
324 | | ret = _gnutls_buffer_pop_prefix32(b, &s, 0); \ |
325 | | if (ret < 0) { \ |
326 | | gnutls_assert(); \ |
327 | | goto error; \ |
328 | | } \ |
329 | | v = (v << 32) | s; \ |
330 | | ret = _gnutls_buffer_pop_prefix32(b, &s, 0); \ |
331 | | if (ret < 0) { \ |
332 | | gnutls_assert(); \ |
333 | | goto error; \ |
334 | | } \ |
335 | | o.tv_sec = v; \ |
336 | | o.tv_nsec = s; \ |
337 | | } |
338 | | |
339 | | #endif /* GNUTLS_LIB_STR_H */ |