| line |
true |
false |
branch |
|
52
|
0 |
2 |
assert(BT_MIN_PIECE_LENGTH == bt_default_piece_length(0, 0)); |
|
72
|
1 |
3 |
for (i = 0; i < vect->size; i++) { |
|
86
|
0 |
1 |
assert(ctx != NULL); |
|
111
|
2 |
0 |
if (vect->size >= vect->allocated) { |
|
112
|
0 |
2 |
size_t size = (vect->allocated == 0 ? 128 : vect->allocated * 2); |
|
114
|
0 |
2 |
if (new_array == NULL) return 0; /* failed: no memory */ |
|
135
|
2 |
0 |
if ((ctx->piece_count % BT_BLOCK_SIZE) == 0) { |
|
137
|
0 |
2 |
if (!block) |
|
139
|
0 |
2 |
if (!bt_vector_add_ptr(&ctx->hash_blocks, block)) { |
|
174
|
0 |
0 |
if (info == NULL) { |
|
181
|
0 |
0 |
if (!bt_vector_add_ptr(&ctx->files, info)) { |
|
187
|
0 |
0 |
if (ctx->piece_count == 0 && ctx->index == 0) { |
|
|
0 |
0 |
if (ctx->piece_count == 0 && ctx->index == 0) { |
|
206
|
0 |
2 |
assert(ctx->index < ctx->piece_length); |
|
208
|
2 |
0 |
while (size > 0) { |
|
211
|
2 |
0 |
if (size < rest) { |
|
235
|
2 |
0 |
if (ctx->index > 0) { |
|
240
|
2 |
0 |
if (result) memcpy(result, ctx->btih, btih_hash_size); |
|
256
|
0 |
20 |
if (ctx->error) |
|
258
|
4 |
16 |
if (length >= ctx->content.allocated) { |
|
260
|
2 |
2 |
if (length < 64) length = 64; |
|
263
|
0 |
4 |
if (new_str == NULL) { |
|
283
|
0 |
14 |
if (!bt_str_ensure_length(ctx, ctx->content.length + length + 1)) |
|
285
|
0 |
14 |
assert(ctx->content.str != 0); |
|
300
|
4 |
0 |
if (name) |
|
304
|
0 |
4 |
if (!bt_str_ensure_length(ctx, ctx->content.length + 22)) |
|
328
|
0 |
0 |
if (name) |
|
330
|
0 |
0 |
if (!bt_str_ensure_length(ctx, ctx->content.length + string_length + 21)) |
|
352
|
0 |
2 |
if (!bt_str_ensure_length(ctx, ctx->content.length + pieces_length + 21)) |
|
361
|
2 |
2 |
for (bytes_left = pieces_length, i = 0; bytes_left > 0; i++) |
|
384
|
18 |
2 |
for (hi_bit = 8388608; hi_bit > size; hi_bit >>= 1); |
|
404
|
0 |
0 |
for (i = 0; i < 6 && total_size >= sizes[i]; i++); |
|
|
0 |
0 |
for (i = 0; i < 6 && total_size >= sizes[i]; i++); |
|
411
|
0 |
2 |
transmission_piece_length(total_size) : utorr_piece_length(total_size)); |
|
418
|
0 |
0 |
for (; p >= path && *p != '/' && *p != '\\'; p--); |
|
|
0 |
0 |
for (; p >= path && *p != '/' && *p != '\\'; p--); |
|
|
0 |
0 |
for (; p >= path && *p != '/' && *p != '\\'; p--); |
|
426
|
0 |
0 |
for (; p > path && (*p == '/' || *p == '\\'); p--) *p = 0; |
|
|
0 |
0 |
for (; p > path && (*p == '/' || *p == '\\'); p--) *p = 0; |
|
|
0 |
0 |
for (; p > path && (*p == '/' || *p == '\\'); p--) *p = 0; |
|
427
|
0 |
0 |
if (p <= path) return "BATCH_DIR"; |
|
451
|
0 |
2 |
assert(ctx->content.str == NULL); |
|
453
|
0 |
2 |
if (ctx->piece_length == 0) { |
|
454
|
0 |
0 |
if (ctx->files.size == 1) { |
|
460
|
2 |
0 |
if ((ctx->options & BT_OPT_INFOHASH_ONLY) == 0) { |
|
463
|
0 |
2 |
if (ctx->announce.array && ctx->announce.size > 0) { |
|
|
0 |
0 |
if (ctx->announce.array && ctx->announce.size > 0) { |
|
467
|
0 |
0 |
if (ctx->announce.size > 1) { |
|
472
|
0 |
0 |
for (i = 0; i < ctx->announce.size; i++) { |
|
473
|
0 |
0 |
if (i > 0) { |
|
482
|
0 |
2 |
if (ctx->program_name) { |
|
495
|
0 |
2 |
if (ctx->files.size > 1) { |
|
502
|
0 |
0 |
for (i = 0; i < ctx->files.size; i++) { |
|
511
|
0 |
2 |
else if (ctx->files.size > 0) { |
|
522
|
0 |
2 |
if (ctx->options & BT_OPT_PRIVATE) { |
|
524
|
0 |
2 |
} else if (ctx->options & BT_OPT_TRANSMISSION) { |
|
531
|
2 |
0 |
if (ctx->content.str) { |
|
620
|
0 |
0 |
if (!announce_url || announce_url[0] == '\0') return 0; |
|
|
0 |
0 |
if (!announce_url || announce_url[0] == '\0') return 0; |
|
622
|
0 |
0 |
if (!url_copy) return 0; |
|
623
|
0 |
0 |
if (bt_vector_add_ptr(&ctx->announce, url_copy)) |
|
638
|
0 |
0 |
assert(ctx->content.str); |
|
655
|
0 |
0 |
assert(!!out); |
|
685
|
0 |
0 |
const size_t program_name_length = (ctx->program_name ? strlen(ctx->program_name) : 0); |
|
688
|
0 |
0 |
assert((exported_size + padding_size) == GET_EXPORT_ALIGNED(exported_size)); |
|
689
|
0 |
0 |
if (out_ptr) { |
|
692
|
0 |
0 |
if (size < exported_size) |
|
704
|
0 |
0 |
for (i = 0; i < ctx->hash_blocks.size && hash_data_left; i++) { |
|
|
0 |
0 |
for (i = 0; i < ctx->hash_blocks.size && hash_data_left; i++) { |
|
713
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(exported_size)); |
|
715
|
0 |
0 |
for (i = 0; i < ctx->files.size; i++) { |
|
719
|
0 |
0 |
if (!length) |
|
722
|
0 |
0 |
if (out_ptr) { |
|
723
|
0 |
0 |
if (size < exported_size) |
|
731
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(exported_size)); |
|
733
|
0 |
0 |
for (i = 0; i < ctx->announce.size; i++) { |
|
736
|
0 |
0 |
if (!length) |
|
739
|
0 |
0 |
if (out_ptr) { |
|
740
|
0 |
0 |
if (size < exported_size) |
|
746
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(exported_size)); |
|
748
|
0 |
0 |
if (program_name_length > 0) { |
|
751
|
0 |
0 |
if (out_ptr) { |
|
752
|
0 |
0 |
if (size < exported_size) |
|
757
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(exported_size)); |
|
760
|
0 |
0 |
if (ctx->content.length > 0) { |
|
763
|
0 |
0 |
if (out_ptr) { |
|
764
|
0 |
0 |
if (size < exported_size) |
|
766
|
0 |
0 |
assert(ctx->content.str != NULL); |
|
770
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(exported_size)); |
|
772
|
0 |
0 |
assert(!out || (size_t)(out_ptr - (char*)out) == exported_size); |
|
|
0 |
0 |
assert(!out || (size_t)(out_ptr - (char*)out) == exported_size); |
|
803
|
0 |
0 |
if (size < imported_size) |
|
805
|
0 |
0 |
if (header->torrent_ctx_size != sizeof(torrent_ctx)) |
|
817
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |
|
818
|
0 |
0 |
if (size < imported_size) |
|
821
|
0 |
0 |
while (hash_data_left) { |
|
824
|
0 |
0 |
if (!block) |
|
826
|
0 |
0 |
if (!bt_vector_add_ptr(&ctx->hash_blocks, block)) { |
|
835
|
0 |
0 |
assert((size_t)(in_ptr - (char*)in) == imported_size); |
|
836
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |
|
838
|
0 |
0 |
for (i = 0; i < header->files_size; i++) { |
|
841
|
0 |
0 |
if (size < (imported_size + sizeof(size_t))) |
|
847
|
0 |
0 |
if (!length || size < imported_size) |
|
|
0 |
0 |
if (!length || size < imported_size) |
|
849
|
0 |
0 |
if (!bt_add_file(ctx, in_ptr + sizeof(size_t), filesize)) |
|
853
|
0 |
0 |
assert((size_t)(in_ptr - (char*)in) == imported_size); |
|
854
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |
|
856
|
0 |
0 |
for (i = 0; i < header->announce_size; i++) { |
|
857
|
0 |
0 |
if (size < (imported_size + sizeof(size_t))) |
|
861
|
0 |
0 |
if (!length || size < imported_size) |
|
|
0 |
0 |
if (!length || size < imported_size) |
|
863
|
0 |
0 |
if (!bt_add_announce(ctx, in_ptr + sizeof(size_t))) |
|
867
|
0 |
0 |
assert((size_t)(in_ptr - (char*)in) == imported_size); |
|
868
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |
|
871
|
0 |
0 |
if (length) { |
|
873
|
0 |
0 |
if (size < imported_size) |
|
875
|
0 |
0 |
if (!bt_set_program_name(ctx, in_ptr)) |
|
878
|
0 |
0 |
assert((size_t)(in_ptr - (char*)in) == imported_size); |
|
879
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |
|
893
|
0 |
0 |
if (length) { |
|
895
|
0 |
0 |
if (size < imported_size) |
|
897
|
0 |
0 |
if (!bt_str_ensure_length(ctx, length)) |
|
901
|
0 |
0 |
assert((size_t)(in_ptr - (char*)in) == imported_size); |
|
902
|
0 |
0 |
assert(IS_EXPORT_ALIGNED(imported_size)); |