Skip to content

Commit

Permalink
Fix unsigned numbers in i commands JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Jan 10, 2024
1 parent a666628 commit 75995fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions librz/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2359,8 +2359,8 @@ static void sections_print_json(RzCore *core, PJ *pj, RzBinObject *o, RzBinSecti

pj_o(pj);
pj_ks(pj, "name", section->name);
pj_kN(pj, "size", section->size);
pj_kN(pj, "vsize", section->vsize);
pj_kn(pj, "size", section->size);
pj_kn(pj, "vsize", section->vsize);
pj_ks(pj, "perm", perms);
if (!section->is_segment) {
char *section_type = rz_bin_section_type_to_string(core->bin, section->type);
Expand All @@ -2382,10 +2382,10 @@ static void sections_print_json(RzCore *core, PJ *pj, RzBinObject *o, RzBinSecti
}
rz_list_free(flags);
}
pj_kN(pj, "paddr", section->paddr);
pj_kN(pj, "vaddr", addr);
pj_kn(pj, "paddr", section->paddr);
pj_kn(pj, "vaddr", addr);
if (section->align) {
pj_kN(pj, "align", section->align);
pj_kn(pj, "align", section->align);
}
if (hashes && section->size > 0) {
HtPP *digests = rz_core_bin_create_digests(core, section->paddr, section->size, hashes);
Expand Down Expand Up @@ -2974,7 +2974,7 @@ RZ_API bool rz_core_file_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFil
pj_ki(state->d.pj, "fd", desc->fd);
if (fsz != UT64_MAX) {
char humansz[8];
pj_kN(state->d.pj, "size", fsz);
pj_kn(state->d.pj, "size", fsz);
rz_num_units(humansz, sizeof(humansz), fsz);
pj_ks(state->d.pj, "humansz", humansz);
}
Expand Down Expand Up @@ -3866,7 +3866,7 @@ RZ_API bool rz_core_bin_class_fields_print(RZ_NONNULL RzCore *core, RZ_NONNULL R
if (f->flags) {
flags_to_json(state->d.pj, f->flags);
}
pj_kN(state->d.pj, "addr", f->vaddr);
pj_kn(state->d.pj, "addr", f->vaddr);
pj_end(state->d.pj);
}
break;
Expand Down Expand Up @@ -3928,7 +3928,7 @@ RZ_API bool rz_core_bin_class_methods_print(RZ_NONNULL RzCore *core, RZ_NONNULL
if (sym->method_flags) {
flags_to_json(state->d.pj, sym->method_flags);
}
pj_kN(state->d.pj, "addr", sym->vaddr);
pj_kn(state->d.pj, "addr", sym->vaddr);
pj_end(state->d.pj);
break;
case RZ_OUTPUT_MODE_TABLE:
Expand Down Expand Up @@ -4000,7 +4000,7 @@ RZ_API bool rz_core_bin_classes_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinF
case RZ_OUTPUT_MODE_JSON:
pj_o(state->d.pj);
pj_ks(state->d.pj, "classname", c->name);
pj_kN(state->d.pj, "addr", c->addr);
pj_kn(state->d.pj, "addr", c->addr);
if (c->super) {
pj_ks(state->d.pj, "visibility", c->visibility_str ? c->visibility_str : "");
pj_ks(state->d.pj, "super", c->super);
Expand All @@ -4012,7 +4012,7 @@ RZ_API bool rz_core_bin_classes_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinF
if (sym->method_flags) {
flags_to_json(state->d.pj, sym->method_flags);
}
pj_kN(state->d.pj, "addr", sym->vaddr);
pj_kn(state->d.pj, "addr", sym->vaddr);
pj_end(state->d.pj);
}
pj_end(state->d.pj);
Expand All @@ -4026,7 +4026,7 @@ RZ_API bool rz_core_bin_classes_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinF
if (f->flags) {
flags_to_json(state->d.pj, f->flags);
}
pj_kN(state->d.pj, "addr", f->vaddr);
pj_kn(state->d.pj, "addr", f->vaddr);
pj_end(state->d.pj);
}
pj_end(state->d.pj);
Expand Down Expand Up @@ -4095,8 +4095,8 @@ RZ_API bool rz_core_bin_fields_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFi
case RZ_OUTPUT_MODE_JSON:
pj_o(state->d.pj);
pj_ks(state->d.pj, "name", field->name);
pj_kN(state->d.pj, "vaddr", field->vaddr);
pj_kN(state->d.pj, "paddr", field->paddr);
pj_kn(state->d.pj, "vaddr", field->vaddr);
pj_kn(state->d.pj, "paddr", field->paddr);
if (field->comment && *field->comment) {
pj_ks(state->d.pj, "comment", field->comment);
}
Expand Down Expand Up @@ -4590,8 +4590,8 @@ static void core_bin_file_print(RzCore *core, RzBinFile *bf, RzCmdStateOutput *s
pj_ko(state->d.pj, "obj");
pj_ks(state->d.pj, "arch", arch);
pj_ki(state->d.pj, "bits", bits);
pj_kN(state->d.pj, "binoffset", obj->boffset);
pj_kN(state->d.pj, "objsize", obj->obj_size);
pj_kn(state->d.pj, "binoffset", obj->boffset);
pj_kn(state->d.pj, "objsize", obj->obj_size);
pj_end(state->d.pj);
pj_end(state->d.pj);
break;
Expand Down
2 changes: 1 addition & 1 deletion test/db/cmd/cmd_i
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,7 @@ NAME=iSj
FILE=bins/elf/analysis/x86-helloworld-gcc
CMDS=iSj
EXPECT=<<EOF
[{"name":"","size":0,"vsize":0,"perm":"----","type":"NULL","paddr":0,"vaddr":-1},{"name":".interp","size":19,"vsize":19,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":308,"vaddr":134512948},{"name":".note.ABI-tag","size":32,"vsize":32,"perm":"-r--","type":"NOTE","flags":["alloc"],"paddr":328,"vaddr":134512968},{"name":".note.gnu.build-id","size":36,"vsize":36,"perm":"-r--","type":"NOTE","flags":["alloc"],"paddr":360,"vaddr":134513000},{"name":".gnu.hash","size":32,"vsize":32,"perm":"-r--","type":"GNU_HASH","flags":["alloc"],"paddr":396,"vaddr":134513036},{"name":".dynsym","size":80,"vsize":80,"perm":"-r--","type":"DYNSYM","flags":["alloc"],"paddr":428,"vaddr":134513068},{"name":".dynstr","size":74,"vsize":74,"perm":"-r--","type":"STRTAB","flags":["alloc"],"paddr":508,"vaddr":134513148},{"name":".gnu.version","size":10,"vsize":10,"perm":"-r--","type":"VERSYM","flags":["alloc"],"paddr":582,"vaddr":134513222},{"name":".gnu.version_r","size":32,"vsize":32,"perm":"-r--","type":"VERNEED","flags":["alloc"],"paddr":592,"vaddr":134513232},{"name":".rel.dyn","size":8,"vsize":8,"perm":"-r--","type":"REL","flags":["alloc"],"paddr":624,"vaddr":134513264},{"name":".rel.plt","size":24,"vsize":24,"perm":"-r--","type":"REL","flags":["alloc"],"paddr":632,"vaddr":134513272},{"name":".init","size":35,"vsize":35,"perm":"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":656,"vaddr":134513296},{"name":".plt","size":64,"vsize":64,"perm":"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":704,"vaddr":134513344},{"name":".text","size":404,"vsize":404,"perm":"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":768,"vaddr":134513408},{"name":".fini","size":20,"vsize":20,"perm":"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":1172,"vaddr":134513812},{"name":".rodata","size":21,"vsize":21,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":1192,"vaddr":134513832},{"name":".eh_frame_hdr","size":44,"vsize":44,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":1216,"vaddr":134513856},{"name":".eh_frame","size":176,"vsize":176,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":1260,"vaddr":134513900},{"name":".init_array","size":4,"vsize":4,"perm":"-rw-","type":"INIT_ARRAY","flags":["write","alloc"],"paddr":1436,"vaddr":134518172},{"name":".fini_array","size":4,"vsize":4,"perm":"-rw-","type":"FINI_ARRAY","flags":["write","alloc"],"paddr":1440,"vaddr":134518176},{"name":".jcr","size":4,"vsize":4,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1444,"vaddr":134518180},{"name":".dynamic","size":232,"vsize":232,"perm":"-rw-","type":"DYNAMIC","flags":["write","alloc"],"paddr":1448,"vaddr":134518184},{"name":".got","size":4,"vsize":4,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1680,"vaddr":134518416},{"name":".got.plt","size":24,"vsize":24,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1684,"vaddr":134518420},{"name":".data","size":8,"vsize":8,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1708,"vaddr":134518444},{"name":".bss","size":0,"vsize":4,"perm":"-rw-","type":"NOBITS","flags":["write","alloc"],"paddr":1716,"vaddr":134518452},{"name":".comment","size":17,"vsize":17,"perm":"----","type":"PROGBITS","flags":["merge","strings"],"paddr":1716,"vaddr":-1},{"name":".shstrtab","size":262,"vsize":262,"perm":"----","type":"STRTAB","paddr":1733,"vaddr":-1},{"name":".symtab","size":1104,"vsize":1104,"perm":"----","type":"SYMTAB","paddr":3196,"vaddr":-1},{"name":".strtab","size":599,"vsize":599,"perm":"----","type":"STRTAB","paddr":4300,"vaddr":-1}]
[{"name":"","size":0,"vsize":0,"perm":"----","type":"NULL","paddr":0,"vaddr":18446744073709551615},{"name": ".interp","size":19,"vsize":19,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":308,"vaddr":134512 948},{"name":".note.ABI-tag","size":32,"vsize":32,"perm":"-r--","type":"NOTE","flags":["alloc"],"paddr":328 ,"vaddr":134512968},{"name":".note.gnu.build-id","size":36,"vsize":36,"perm":"-r--","type":"NOTE","flags":[ "alloc"],"paddr":360,"vaddr":134513000},{"name":".gnu.hash","size":32,"vsize":32,"perm":"-r--","type":"GNU_ HASH","flags":["alloc"],"paddr":396,"vaddr":134513036},{"name":".dynsym","size":80,"vsize":80,"perm":"-r--" ,"type":"DYNSYM","flags":["alloc"],"paddr":428,"vaddr":134513068},{"name":".dynstr","size":74,"vsize":74,"p erm":"-r--","type":"STRTAB","flags":["alloc"],"paddr":508,"vaddr":134513148},{"name":".gnu.version","size": 10,"vsize":10,"perm":"-r--","type":"VERSYM","flags":["alloc"],"paddr":582,"vaddr":134513222},{"name":".gnu. version_r","size":32,"vsize":32,"perm":"-r--","type":"VERNEED","flags":["alloc"],"paddr":592,"vaddr":134513 232},{"name":".rel.dyn","size":8,"vsize":8,"perm":"-r--","type":"REL","flags":["alloc"],"paddr":624,"vaddr" :134513264},{"name":".rel.plt","size":24,"vsize":24,"perm":"-r--","type":"REL","flags":["alloc"],"paddr":63 2,"vaddr":134513272},{"name":".init","size":35,"vsize":35,"perm":"-r-x","type":"PROGBITS","flags":["alloc", "execute"],"paddr":656,"vaddr":134513296},{"name":".plt","size":64,"vsize":64,"perm":"-r-x","type":"PROGBIT S","flags":["alloc","execute"],"paddr":704,"vaddr":134513344},{"name":".text","size":404,"vsize":404,"perm" :"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":768,"vaddr":134513408},{"name":".fini","size" :20,"vsize":20,"perm":"-r-x","type":"PROGBITS","flags":["alloc","execute"],"paddr":1172,"vaddr":134513812}, {"name":".rodata","size":21,"vsize":21,"perm":"-r--","type":"PROGBITS","flags":["alloc"],"paddr":1192,"vadd r":134513832},{"name":".eh_frame_hdr","size":44,"vsize":44,"perm":"-r--","type":"PROGBITS","flags":["alloc" ],"paddr":1216,"vaddr":134513856},{"name":".eh_frame","size":176,"vsize":176,"perm":"-r--","type":"PROGBITS ","flags":["alloc"],"paddr":1260,"vaddr":134513900},{"name":".init_array","size":4,"vsize":4,"perm":"-rw-", "type":"INIT_ARRAY","flags":["write","alloc"],"paddr":1436,"vaddr":134518172},{"name":".fini_array","size": 4,"vsize":4,"perm":"-rw-","type":"FINI_ARRAY","flags":["write","alloc"],"paddr":1440,"vaddr":134518176},{"n ame":".jcr","size":4,"vsize":4,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1444,"vadd r":134518180},{"name":".dynamic","size":232,"vsize":232,"perm":"-rw-","type":"DYNAMIC","flags":["write","al loc"],"paddr":1448,"vaddr":134518184},{"name":".got","size":4,"vsize":4,"perm":"-rw-","type":"PROGBITS","fl ags":["write","alloc"],"paddr":1680,"vaddr":134518416},{"name":".got.plt","size":24,"vsize":24,"perm":"-rw- ","type":"PROGBITS","flags":["write","alloc"],"paddr":1684,"vaddr":134518420},{"name":".data","size":8,"vsi ze":8,"perm":"-rw-","type":"PROGBITS","flags":["write","alloc"],"paddr":1708,"vaddr":134518444},{"name":".b ss","size":0,"vsize":4,"perm":"-rw-","type":"NOBITS","flags":["write","alloc"],"paddr":1716,"vaddr":1345184 52},{"name":".comment","size":17,"vsize":17,"perm":"----","type":"PROGBITS","flags":["merge","strings"],"pa ddr":1716,"vaddr":18446744073709551615},{"name":".shstrtab","size":262,"vsize":262,"perm":"----","type":"ST RTAB","paddr":1733,"vaddr":18446744073709551615},{"name":".symtab","size":1104,"vsize":1104,"perm":"----"," type":"SYMTAB","paddr":3196,"vaddr":18446744073709551615},{"name":".strtab","size":599,"vsize":599,"perm":"----","type":"STRTAB","paddr":4300,"vaddr":18446744073709551615}]
EOF
RUN

Expand Down

0 comments on commit 75995fe

Please sign in to comment.