1 1.1 christos /* 2 1.1 christos * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the OpenSSL license (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #include <string.h> 11 1.1 christos #include <openssl/buffer.h> 12 1.1 christos 13 1.1 christos #ifdef __VMS 14 1.1 christos # pragma names save 15 1.1 christos # pragma names as_is,shortened 16 1.1 christos #endif 17 1.1 christos 18 1.1 christos #include "../ssl/packet_local.h" 19 1.1 christos 20 1.1 christos #ifdef __VMS 21 1.1 christos # pragma names restore 22 1.1 christos #endif 23 1.1 christos 24 1.1 christos #include "testutil.h" 25 1.1 christos 26 1.1 christos static const unsigned char simple1[] = { 0xff }; 27 1.1 christos static const unsigned char simple2[] = { 0x01, 0xff }; 28 1.1 christos static const unsigned char simple3[] = { 0x00, 0x00, 0x00, 0x01, 0xff }; 29 1.1 christos static const unsigned char nestedsub[] = { 0x03, 0xff, 0x01, 0xff }; 30 1.1 christos static const unsigned char seqsub[] = { 0x01, 0xff, 0x01, 0xff }; 31 1.1 christos static const unsigned char empty[] = { 0x00 }; 32 1.1 christos static const unsigned char alloc[] = { 0x02, 0xfe, 0xff }; 33 1.1 christos static const unsigned char submem[] = { 0x03, 0x02, 0xfe, 0xff }; 34 1.1 christos static const unsigned char fixed[] = { 0xff, 0xff, 0xff }; 35 1.1 christos 36 1.1 christos static BUF_MEM *buf; 37 1.1 christos 38 1.1 christos static int cleanup(WPACKET *pkt) 39 1.1 christos { 40 1.1 christos WPACKET_cleanup(pkt); 41 1.1 christos return 0; 42 1.1 christos } 43 1.1 christos 44 1.1 christos static int test_WPACKET_init(void) 45 1.1 christos { 46 1.1 christos WPACKET pkt; 47 1.1 christos int i; 48 1.1 christos size_t written; 49 1.1 christos unsigned char sbuf[3]; 50 1.1 christos 51 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 52 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 53 1.1 christos /* Closing a top level WPACKET should fail */ 54 1.1 christos || !TEST_false(WPACKET_close(&pkt)) 55 1.1 christos /* Finishing a top level WPACKET should succeed */ 56 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 57 1.1 christos /* 58 1.1 christos * Can't call close or finish on a WPACKET that's already 59 1.1 christos * finished. 60 1.1 christos */ 61 1.1 christos || !TEST_false(WPACKET_close(&pkt)) 62 1.1 christos || !TEST_false(WPACKET_finish(&pkt)) 63 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 64 1.1 christos || !TEST_mem_eq(buf->data, written, simple1, sizeof(simple1))) 65 1.1 christos return cleanup(&pkt); 66 1.1 christos 67 1.1 christos /* Now try with a one byte length prefix */ 68 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 69 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 70 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 71 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 72 1.1 christos || !TEST_mem_eq(buf->data, written, simple2, sizeof(simple2))) 73 1.1 christos return cleanup(&pkt); 74 1.1 christos 75 1.1 christos /* And a longer length prefix */ 76 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 4)) 77 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 78 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 79 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 80 1.1 christos || !TEST_mem_eq(buf->data, written, simple3, sizeof(simple3))) 81 1.1 christos return cleanup(&pkt); 82 1.1 christos 83 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1))) 84 1.1 christos return cleanup(&pkt); 85 1.1 christos for (i = 1; i < 257; i++) { 86 1.1 christos /* 87 1.1 christos * Putting more bytes in than fit for the size of the length prefix 88 1.1 christos * should fail 89 1.1 christos */ 90 1.1 christos if (!TEST_int_eq(WPACKET_put_bytes_u8(&pkt, 0xff), i < 256)) 91 1.1 christos return cleanup(&pkt); 92 1.1 christos } 93 1.1 christos if (!TEST_true(WPACKET_finish(&pkt))) 94 1.1 christos return cleanup(&pkt); 95 1.1 christos 96 1.1 christos /* Test initialising from a fixed size buffer */ 97 1.1 christos if (!TEST_true(WPACKET_init_static_len(&pkt, sbuf, sizeof(sbuf), 0)) 98 1.1 christos /* Adding 3 bytes should succeed */ 99 1.1 christos || !TEST_true(WPACKET_put_bytes_u24(&pkt, 0xffffff)) 100 1.1 christos /* Adding 1 more byte should fail */ 101 1.1 christos || !TEST_false(WPACKET_put_bytes_u8(&pkt, 0xff)) 102 1.1 christos /* Finishing the top level WPACKET should succeed */ 103 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 104 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 105 1.1 christos || !TEST_mem_eq(sbuf, written, fixed, sizeof(sbuf)) 106 1.1 christos /* Initialise with 1 len byte */ 107 1.1 christos || !TEST_true(WPACKET_init_static_len(&pkt, sbuf, sizeof(sbuf), 1)) 108 1.1 christos /* Adding 2 bytes should succeed */ 109 1.1 christos || !TEST_true(WPACKET_put_bytes_u16(&pkt, 0xfeff)) 110 1.1 christos /* Adding 1 more byte should fail */ 111 1.1 christos || !TEST_false(WPACKET_put_bytes_u8(&pkt, 0xff)) 112 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 113 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 114 1.1 christos || !TEST_mem_eq(sbuf, written, alloc, sizeof(alloc))) 115 1.1 christos return cleanup(&pkt); 116 1.1 christos 117 1.1 christos return 1; 118 1.1 christos } 119 1.1 christos 120 1.1 christos static int test_WPACKET_set_max_size(void) 121 1.1 christos { 122 1.1 christos WPACKET pkt; 123 1.1 christos size_t written; 124 1.1 christos 125 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 126 1.1 christos /* 127 1.1 christos * No previous lenbytes set so we should be ok to set the max 128 1.1 christos * possible max size 129 1.1 christos */ 130 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, SIZE_MAX)) 131 1.1 christos /* We should be able to set it smaller too */ 132 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, SIZE_MAX -1)) 133 1.1 christos /* And setting it bigger again should be ok */ 134 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, SIZE_MAX)) 135 1.1 christos || !TEST_true(WPACKET_finish(&pkt))) 136 1.1 christos return cleanup(&pkt); 137 1.1 christos 138 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 139 1.1 christos /* 140 1.1 christos * Should fail because we already consumed 1 byte with the 141 1.1 christos * length 142 1.1 christos */ 143 1.1 christos || !TEST_false(WPACKET_set_max_size(&pkt, 0)) 144 1.1 christos /* 145 1.1 christos * Max size can't be bigger than biggest that will fit in 146 1.1 christos * lenbytes 147 1.1 christos */ 148 1.1 christos || !TEST_false(WPACKET_set_max_size(&pkt, 0x0101)) 149 1.1 christos /* It can be the same as the maximum possible size */ 150 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, 0x0100)) 151 1.1 christos /* Or it can be less */ 152 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, 0x01)) 153 1.1 christos /* Should fail because packet is already filled */ 154 1.1 christos || !TEST_false(WPACKET_put_bytes_u8(&pkt, 0xff)) 155 1.1 christos /* You can't put in more bytes than max size */ 156 1.1 christos || !TEST_true(WPACKET_set_max_size(&pkt, 0x02)) 157 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 158 1.1 christos || !TEST_false(WPACKET_put_bytes_u8(&pkt, 0xff)) 159 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 160 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 161 1.1 christos || !TEST_mem_eq(buf->data, written, simple2, sizeof(simple2))) 162 1.1 christos return cleanup(&pkt); 163 1.1 christos 164 1.1 christos return 1; 165 1.1 christos } 166 1.1 christos 167 1.1 christos static int test_WPACKET_start_sub_packet(void) 168 1.1 christos { 169 1.1 christos WPACKET pkt; 170 1.1 christos size_t written; 171 1.1 christos size_t len; 172 1.1 christos 173 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 174 1.1 christos || !TEST_true(WPACKET_start_sub_packet(&pkt)) 175 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 176 1.1 christos /* Can't finish because we have a sub packet */ 177 1.1 christos || !TEST_false(WPACKET_finish(&pkt)) 178 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 179 1.1 christos /* Sub packet is closed so can't close again */ 180 1.1 christos || !TEST_false(WPACKET_close(&pkt)) 181 1.1 christos /* Now a top level so finish should succeed */ 182 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 183 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 184 1.1 christos || !TEST_mem_eq(buf->data, written, simple1, sizeof(simple1))) 185 1.1 christos return cleanup(&pkt); 186 1.1 christos 187 1.1 christos /* Single sub-packet with length prefix */ 188 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 189 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 190 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 191 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 192 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 193 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 194 1.1 christos || !TEST_mem_eq(buf->data, written, simple2, sizeof(simple2))) 195 1.1 christos return cleanup(&pkt); 196 1.1 christos 197 1.1 christos /* Nested sub-packets with length prefixes */ 198 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 199 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 200 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 201 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 202 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 203 1.1 christos || !TEST_true(WPACKET_get_length(&pkt, &len)) 204 1.1 christos || !TEST_size_t_eq(len, 1) 205 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 206 1.1 christos || !TEST_true(WPACKET_get_length(&pkt, &len)) 207 1.1 christos || !TEST_size_t_eq(len, 3) 208 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 209 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 210 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 211 1.1 christos || !TEST_mem_eq(buf->data, written, nestedsub, sizeof(nestedsub))) 212 1.1 christos return cleanup(&pkt); 213 1.1 christos 214 1.1 christos /* Sequential sub-packets with length prefixes */ 215 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 216 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 217 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 218 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 219 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 220 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 221 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 222 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 223 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 224 1.1 christos || !TEST_mem_eq(buf->data, written, seqsub, sizeof(seqsub))) 225 1.1 christos return cleanup(&pkt); 226 1.1 christos 227 1.1 christos /* Nested sub-packets with lengths filled before finish */ 228 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 229 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 230 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 231 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 232 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 233 1.1 christos || !TEST_true(WPACKET_get_length(&pkt, &len)) 234 1.1 christos || !TEST_size_t_eq(len, 1) 235 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 236 1.1 christos || !TEST_true(WPACKET_get_length(&pkt, &len)) 237 1.1 christos || !TEST_size_t_eq(len, 3) 238 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 239 1.1 christos || !TEST_true(WPACKET_fill_lengths(&pkt)) 240 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 241 1.1 christos || !TEST_mem_eq(buf->data, written, nestedsub, sizeof(nestedsub)) 242 1.1 christos || !TEST_true(WPACKET_finish(&pkt))) 243 1.1 christos return cleanup(&pkt); 244 1.1 christos 245 1.1 christos return 1; 246 1.1 christos } 247 1.1 christos 248 1.1 christos 249 1.1 christos static int test_WPACKET_set_flags(void) 250 1.1 christos { 251 1.1 christos WPACKET pkt; 252 1.1 christos size_t written; 253 1.1 christos 254 1.1 christos /* Set packet to be non-zero length */ 255 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 256 1.1 christos || !TEST_true(WPACKET_set_flags(&pkt, WPACKET_FLAGS_NON_ZERO_LENGTH)) 257 1.1 christos /* Should fail because of zero length */ 258 1.1 christos || !TEST_false(WPACKET_finish(&pkt)) 259 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 260 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 261 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 262 1.1 christos || !TEST_mem_eq(buf->data, written, simple1, sizeof(simple1))) 263 1.1 christos return cleanup(&pkt); 264 1.1 christos 265 1.1 christos /* Repeat above test in a sub-packet */ 266 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 267 1.1 christos || !TEST_true(WPACKET_start_sub_packet(&pkt)) 268 1.1 christos || !TEST_true(WPACKET_set_flags(&pkt, WPACKET_FLAGS_NON_ZERO_LENGTH)) 269 1.1 christos /* Should fail because of zero length */ 270 1.1 christos || !TEST_false(WPACKET_close(&pkt)) 271 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 272 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 273 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 274 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 275 1.1 christos || !TEST_mem_eq(buf->data, written, simple1, sizeof(simple1))) 276 1.1 christos return cleanup(&pkt); 277 1.1 christos 278 1.1 christos /* Set packet to abandon non-zero length */ 279 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 280 1.1 christos || !TEST_true(WPACKET_set_flags(&pkt, WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH)) 281 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 282 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 283 1.1 christos || !TEST_size_t_eq(written, 0)) 284 1.1 christos return cleanup(&pkt); 285 1.1 christos 286 1.1 christos /* Repeat above test but only abandon a sub-packet */ 287 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 288 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 289 1.1 christos || !TEST_true(WPACKET_set_flags(&pkt, WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH)) 290 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 291 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 292 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 293 1.1 christos || !TEST_mem_eq(buf->data, written, empty, sizeof(empty))) 294 1.1 christos return cleanup(&pkt); 295 1.1 christos 296 1.1 christos /* And repeat with a non empty sub-packet */ 297 1.1 christos if (!TEST_true(WPACKET_init(&pkt, buf)) 298 1.1 christos || !TEST_true(WPACKET_start_sub_packet_u8(&pkt)) 299 1.1 christos || !TEST_true(WPACKET_set_flags(&pkt, WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH)) 300 1.1 christos || !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xff)) 301 1.1 christos || !TEST_true(WPACKET_close(&pkt)) 302 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 303 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 304 1.1 christos || !TEST_mem_eq(buf->data, written, simple2, sizeof(simple2))) 305 1.1 christos return cleanup(&pkt); 306 1.1 christos return 1; 307 1.1 christos } 308 1.1 christos 309 1.1 christos static int test_WPACKET_allocate_bytes(void) 310 1.1 christos { 311 1.1 christos WPACKET pkt; 312 1.1 christos size_t written; 313 1.1 christos unsigned char *bytes; 314 1.1 christos 315 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 316 1.1 christos || !TEST_true(WPACKET_allocate_bytes(&pkt, 2, &bytes))) 317 1.1 christos return cleanup(&pkt); 318 1.1 christos bytes[0] = 0xfe; 319 1.1 christos bytes[1] = 0xff; 320 1.1 christos if (!TEST_true(WPACKET_finish(&pkt)) 321 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 322 1.1 christos || !TEST_mem_eq(buf->data, written, alloc, sizeof(alloc))) 323 1.1 christos return cleanup(&pkt); 324 1.1 christos 325 1.1 christos /* Repeat with WPACKET_sub_allocate_bytes */ 326 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 327 1.1 christos || !TEST_true(WPACKET_sub_allocate_bytes_u8(&pkt, 2, &bytes))) 328 1.1 christos return cleanup(&pkt); 329 1.1 christos bytes[0] = 0xfe; 330 1.1 christos bytes[1] = 0xff; 331 1.1 christos if (!TEST_true(WPACKET_finish(&pkt)) 332 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 333 1.1 christos || !TEST_mem_eq(buf->data, written, submem, sizeof(submem))) 334 1.1 christos return cleanup(&pkt); 335 1.1 christos 336 1.1 christos return 1; 337 1.1 christos } 338 1.1 christos 339 1.1 christos static int test_WPACKET_memcpy(void) 340 1.1 christos { 341 1.1 christos WPACKET pkt; 342 1.1 christos size_t written; 343 1.1 christos const unsigned char bytes[] = { 0xfe, 0xff }; 344 1.1 christos 345 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 346 1.1 christos || !TEST_true(WPACKET_memcpy(&pkt, bytes, sizeof(bytes))) 347 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 348 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 349 1.1 christos || !TEST_mem_eq(buf->data, written, alloc, sizeof(alloc))) 350 1.1 christos return cleanup(&pkt); 351 1.1 christos 352 1.1 christos /* Repeat with WPACKET_sub_memcpy() */ 353 1.1 christos if (!TEST_true(WPACKET_init_len(&pkt, buf, 1)) 354 1.1 christos || !TEST_true(WPACKET_sub_memcpy_u8(&pkt, bytes, sizeof(bytes))) 355 1.1 christos || !TEST_true(WPACKET_finish(&pkt)) 356 1.1 christos || !TEST_true(WPACKET_get_total_written(&pkt, &written)) 357 1.1 christos || !TEST_mem_eq(buf->data, written, submem, sizeof(submem))) 358 1.1 christos return cleanup(&pkt); 359 1.1 christos 360 1.1 christos return 1; 361 1.1 christos } 362 1.1 christos 363 1.1 christos int setup_tests(void) 364 1.1 christos { 365 1.1 christos if (!TEST_ptr(buf = BUF_MEM_new())) 366 1.1 christos return 0; 367 1.1 christos 368 1.1 christos ADD_TEST(test_WPACKET_init); 369 1.1 christos ADD_TEST(test_WPACKET_set_max_size); 370 1.1 christos ADD_TEST(test_WPACKET_start_sub_packet); 371 1.1 christos ADD_TEST(test_WPACKET_set_flags); 372 1.1 christos ADD_TEST(test_WPACKET_allocate_bytes); 373 1.1 christos ADD_TEST(test_WPACKET_memcpy); 374 1.1 christos return 1; 375 1.1 christos } 376 1.1 christos 377 1.1 christos void cleanup_tests(void) 378 1.1 christos { 379 1.1 christos BUF_MEM_free(buf); 380 1.1 christos } 381