Skip to content

Commit f14c5cb

Browse files
committed
Minor style fixes.
1 parent 192aa99 commit f14c5cb

File tree

1 file changed

+58
-37
lines changed

1 file changed

+58
-37
lines changed

libyara/modules/dex.c

+58-37
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ uint32_t load_encoded_field(
405405
encoded_field.access_flags);
406406
#endif
407407

408-
int name_idx = (int)get_integer(
408+
int name_idx = (int) get_integer(
409409
dex->object, "field_ids[%i].name_idx", *previous_field_idx);
410410

411411
#ifdef DEBUG_DEX_MODULE
@@ -431,10 +431,10 @@ uint32_t load_encoded_field(
431431
index_encoded_field);
432432
}
433433

434-
int class_idx = (int)get_integer(
434+
int class_idx = (int) get_integer(
435435
dex->object, "field_ids[%i].class_idx", *previous_field_idx);
436436

437-
int descriptor_idx = (int)get_integer(
437+
int descriptor_idx = (int) get_integer(
438438
dex->object, "type_ids[%i].descriptor_idx", class_idx);
439439

440440
SIZED_STRING* class_name = get_string(
@@ -457,10 +457,10 @@ uint32_t load_encoded_field(
457457
index_encoded_field);
458458
}
459459

460-
int type_idx = (int)get_integer(dex->object,
460+
int type_idx = (int) get_integer(dex->object,
461461
"field_ids[%i].type_idx", *previous_field_idx);
462462

463-
int shorty_idx = (int)get_integer(dex->object,
463+
int shorty_idx = (int) get_integer(dex->object,
464464
"type_ids[%i].descriptor_idx", type_idx);
465465

466466
SIZED_STRING* proto_name = get_string(dex->object,
@@ -553,7 +553,7 @@ uint32_t load_encoded_method(
553553
encoded_method.code_off);
554554
#endif
555555

556-
int name_idx = (int)get_integer(
556+
int name_idx = (int) get_integer(
557557
dex->object, "method_ids[%i].name_idx", *previous_method_idx);
558558

559559
#ifdef DEBUG_DEX_MODULE
@@ -579,10 +579,10 @@ uint32_t load_encoded_method(
579579
index_encoded_method);
580580
}
581581

582-
int class_idx = (int)get_integer(
582+
int class_idx = (int) get_integer(
583583
dex->object, "method_ids[%i].class_idx", *previous_method_idx);
584584

585-
int descriptor_idx = (int)get_integer(
585+
int descriptor_idx = (int) get_integer(
586586
dex->object, "type_ids[%i].descriptor_idx", class_idx);
587587

588588
SIZED_STRING* class_name = get_string(
@@ -605,10 +605,10 @@ uint32_t load_encoded_method(
605605
index_encoded_method);
606606
}
607607

608-
int proto_idx = (int)get_integer(
608+
int proto_idx = (int) get_integer(
609609
dex->object, "method_ids[%i].proto_idx", *previous_method_idx);
610610

611-
int shorty_idx = (int)get_integer(
611+
int shorty_idx = (int) get_integer(
612612
dex->object, "proto_ids[%i].shorty_idx", proto_idx);
613613

614614
SIZED_STRING* proto_name = get_string(
@@ -691,8 +691,9 @@ void dex_parse(
691691

692692
dex_header = dex->header;
693693

694-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->string_ids_offset),
695-
yr_le32toh(dex_header->string_ids_size) * sizeof(string_id_item_t)))
694+
if (!fits_in_dex(
695+
dex, dex->data + yr_le32toh(dex_header->string_ids_offset),
696+
yr_le32toh(dex_header->string_ids_size) * sizeof(string_id_item_t)))
696697
return;
697698

698699
#ifdef DEBUG_DEX_MODULE
@@ -712,19 +713,22 @@ void dex_parse(
712713
yr_le32toh(string_id_item->string_data_offset));
713714
#endif
714715

715-
if (!fits_in_dex(dex, dex->data + yr_le32toh(string_id_item->string_data_offset),
716-
sizeof(uint32_t)))
716+
if (!fits_in_dex(
717+
dex, dex->data + yr_le32toh(string_id_item->string_data_offset),
718+
sizeof(uint32_t)))
717719
continue;
718720

719-
uint32_t value = (uint32_t)read_uleb128(
720-
(dex->data + yr_le32toh(string_id_item->string_data_offset)), &uleb128_size);
721+
uint32_t value = (uint32_t) read_uleb128(
722+
(dex->data + yr_le32toh(string_id_item->string_data_offset)),
723+
&uleb128_size);
721724

722725
#ifdef DEBUG_DEX_MODULE
723726
printf("[DEX] STRING ID item size:0x%x\n", value);
724727
#endif
725728

726-
if (!fits_in_dex(dex, dex->data + yr_le32toh(string_id_item->string_data_offset),
727-
value))
729+
if (!fits_in_dex(
730+
dex, dex->data + yr_le32toh(string_id_item->string_data_offset),
731+
value))
728732
continue;
729733

730734
set_integer(
@@ -735,15 +739,16 @@ void dex_parse(
735739
"string_ids[%i].size", value);
736740

737741
set_sized_string(
738-
(const char*)((dex->data + yr_le32toh(string_id_item->string_data_offset) + 1)),
742+
(const char*) ((dex->data + yr_le32toh(string_id_item->string_data_offset) + 1)),
739743
value,
740744
dex->object,
741745
"string_ids[%i].value",
742746
i);
743747
}
744748

745-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->type_ids_offset),
746-
yr_le32toh(dex_header->type_ids_size) * sizeof(type_id_item_t)))
749+
if (!fits_in_dex(
750+
dex, dex->data + yr_le32toh(dex_header->type_ids_offset),
751+
yr_le32toh(dex_header->type_ids_size) * sizeof(type_id_item_t)))
747752
return;
748753

749754
#ifdef DEBUG_DEX_MODULE
@@ -754,7 +759,9 @@ void dex_parse(
754759
for (i = 0; i < yr_le32toh(dex_header->type_ids_size); i++)
755760
{
756761
type_id_item_t* type_id_item = (type_id_item_t*) (
757-
dex->data + yr_le32toh(dex_header->type_ids_offset) + i * sizeof(type_id_item_t));
762+
dex->data +
763+
yr_le32toh(dex_header->type_ids_offset) +
764+
i * sizeof(type_id_item_t));
758765

759766
set_integer(
760767
yr_le32toh(type_id_item->descriptor_idx),
@@ -763,8 +770,9 @@ void dex_parse(
763770
i);
764771
}
765772

766-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->proto_ids_offset),
767-
yr_le32toh(dex_header->proto_ids_size) * sizeof(proto_id_item_t)))
773+
if (!fits_in_dex(
774+
dex, dex->data + yr_le32toh(dex_header->proto_ids_offset),
775+
yr_le32toh(dex_header->proto_ids_size) * sizeof(proto_id_item_t)))
768776
return;
769777

770778
#ifdef DEBUG_DEX_MODULE
@@ -775,7 +783,9 @@ void dex_parse(
775783
for (i = 0; i < yr_le32toh(dex_header->proto_ids_size); i++)
776784
{
777785
proto_id_item_t* proto_id_item = (proto_id_item_t*) (
778-
dex->data + yr_le32toh(dex_header->proto_ids_offset) + i * sizeof(proto_id_item_t));
786+
dex->data +
787+
yr_le32toh(dex_header->proto_ids_offset) +
788+
i * sizeof(proto_id_item_t));
779789

780790
set_integer(yr_le32toh(proto_id_item->shorty_idx), dex->object,
781791
"proto_ids[%i].shorty_idx", i);
@@ -785,8 +795,9 @@ void dex_parse(
785795
"proto_ids[%i].parameters_offset", i);
786796
}
787797

788-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->field_ids_offset),
789-
yr_le32toh(dex_header->field_ids_size) * sizeof(field_id_item_t)))
798+
if (!fits_in_dex(
799+
dex, dex->data + yr_le32toh(dex_header->field_ids_offset),
800+
yr_le32toh(dex_header->field_ids_size) * sizeof(field_id_item_t)))
790801
return;
791802

792803
#ifdef DEBUG_DEX_MODULE
@@ -797,7 +808,9 @@ void dex_parse(
797808
for (i = 0; i < yr_le32toh(dex_header->field_ids_size); i++)
798809
{
799810
field_id_item_t* field_id_item = (field_id_item_t*) (
800-
dex->data + yr_le32toh(dex_header->field_ids_offset) + i * sizeof(field_id_item_t));
811+
dex->data +
812+
yr_le32toh(dex_header->field_ids_offset) +
813+
i * sizeof(field_id_item_t));
801814

802815
set_integer(yr_le16toh(field_id_item->class_idx), dex->object,
803816
"field_ids[%i].class_idx", i);
@@ -807,8 +820,9 @@ void dex_parse(
807820
"field_ids[%i].name_idx", i);
808821
}
809822

810-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->method_ids_offset),
811-
yr_le32toh(dex_header->method_ids_size) * sizeof(method_id_item_t)))
823+
if (!fits_in_dex(
824+
dex, dex->data + yr_le32toh(dex_header->method_ids_offset),
825+
yr_le32toh(dex_header->method_ids_size) * sizeof(method_id_item_t)))
812826
return;
813827

814828
#ifdef DEBUG_DEX_MODULE
@@ -839,12 +853,14 @@ void dex_parse(
839853
if (yr_le32toh(dex_header->map_offset) != 0 &&
840854
fits_in_dex(dex, dex->data + yr_le32toh(dex_header->map_offset), sizeof(uint32_t)))
841855
{
842-
uint32_t* map_list_size = (uint32_t *) (dex->data + yr_le32toh(dex_header->map_offset));
856+
uint32_t* map_list_size = (uint32_t *) (
857+
dex->data + yr_le32toh(dex_header->map_offset));
843858

844859
set_integer(yr_le32toh(*map_list_size), dex->object, "map_list.size");
845860

846-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->map_offset),
847-
sizeof(uint32_t) + yr_le32toh(*map_list_size) * sizeof(map_item_t)))
861+
if (!fits_in_dex(
862+
dex, dex->data + yr_le32toh(dex_header->map_offset),
863+
sizeof(uint32_t) + yr_le32toh(*map_list_size) * sizeof(map_item_t)))
848864
return;
849865

850866
for (i = 0; i < yr_le32toh(*map_list_size); i++)
@@ -866,8 +882,9 @@ void dex_parse(
866882
}
867883
}
868884

869-
if (!fits_in_dex(dex, dex->data + yr_le32toh(dex_header->class_defs_offset),
870-
yr_le32toh(dex_header->class_defs_size) * sizeof(class_id_item_t)))
885+
if (!fits_in_dex(
886+
dex, dex->data + yr_le32toh(dex_header->class_defs_offset),
887+
yr_le32toh(dex_header->class_defs_size) * sizeof(class_id_item_t)))
871888
return;
872889

873890
#ifdef DEBUG_DEX_MODULE
@@ -918,8 +935,9 @@ void dex_parse(
918935
{
919936
class_data_item_t class_data_item;
920937

921-
if (!fits_in_dex(dex, dex->data + yr_le32toh(class_id_item->class_data_offset),
922-
4 * sizeof(uint32_t)))
938+
if (!fits_in_dex(
939+
dex, dex->data + yr_le32toh(class_id_item->class_data_offset),
940+
4 * sizeof(uint32_t)))
923941
return;
924942

925943
uleb128_size = 0;
@@ -978,6 +996,7 @@ void dex_parse(
978996
#endif
979997

980998
previous_field_idx = 0;
999+
9811000
for (j = 0; j < class_data_item.instance_fields_size; j++)
9821001
{
9831002
uleb128_size += load_encoded_field(
@@ -995,6 +1014,7 @@ void dex_parse(
9951014
#endif
9961015

9971016
uint32_t previous_method_idx = 0;
1017+
9981018
for (j = 0; j < class_data_item.direct_methods_size; j++)
9991019
{
10001020
uleb128_size += load_encoded_method(
@@ -1012,6 +1032,7 @@ void dex_parse(
10121032
#endif
10131033

10141034
previous_method_idx = 0;
1035+
10151036
for (j = 0; j < class_data_item.virtual_methods_size; j++)
10161037
{
10171038
uleb128_size += load_encoded_method(

0 commit comments

Comments
 (0)