Skip to content

Commit 53e7e92

Browse files
Fix
1 parent 91fc1c1 commit 53e7e92

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/main/java/golanganalyzerextension/version/GolangBuildInfo.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ String find_go_version(Address base_addr) throws BinaryAccessException {
6767

6868
Optional<String> find_module_version(Address base_addr) throws BinaryAccessException {
6969
byte size=(byte)go_bin.get_address_value(base_addr, 14, 1);
70+
byte endian=(byte)go_bin.get_address_value(base_addr, 15, 1);
7071

71-
long addr_value=go_bin.get_address_value(base_addr, 16+size, size);
72-
if(!go_bin.is_valid_address(addr_value)) {
73-
return Optional.empty();
74-
}
75-
Address bytes_addr=go_bin.get_address(go_bin.get_address_value(addr_value, size));
76-
if(!go_bin.is_valid_address(bytes_addr)) {
77-
return Optional.empty();
72+
Address bytes_addr;
73+
long bytes_size;
74+
if((endian&2)==0) {
75+
long addr_value=go_bin.get_address_value(base_addr, 16+size, size);
76+
if(!go_bin.is_valid_address(addr_value)) {
77+
return Optional.empty();
78+
}
79+
bytes_addr=go_bin.get_address(go_bin.get_address_value(addr_value, size));
80+
if(!go_bin.is_valid_address(bytes_addr)) {
81+
return Optional.empty();
82+
}
83+
bytes_size=go_bin.get_address_value(addr_value + size, size);
84+
} else {
85+
long ver_str_size=go_bin.get_address_value(base_addr, 32, 1);
86+
Address go_ver_end_addr=go_bin.get_address(base_addr, 32+1+ver_str_size);
87+
bytes_addr=go_bin.get_address(go_ver_end_addr, 1);
88+
bytes_size=go_bin.get_address_value(go_ver_end_addr, 1);
7889
}
79-
long bytes_size=go_bin.get_address_value(addr_value + size, size);
8090

8191
// runtime/debug/mod.go
8292
Address mod_bytes_addr=go_bin.get_address(bytes_addr, 16);

src/main/java/golanganalyzerextension/version/SysTheVersion.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,19 @@ private boolean is_sys_the_version_string_struct(Address string_struct_addr, Str
108108
if(size!=sys_the_version.length()) {
109109
return false;
110110
}
111+
GolangVersion go_version=new GolangVersion(sys_the_version);
112+
if(go_version.lt("go1.8beta1")) {
113+
return true;
114+
}
111115

112116
// runtime/proc.go
113117
boolean badmorestackg0Msg=false;
114118
boolean badmorestackgsignalMsg=false;
115-
for(int i=-4; i<4; i++) {
119+
for(int i=-8; i<8; i++) {
116120
Address around_str_addr;
117121
String around_str;
118122
try {
119-
around_str_addr=go_bin.get_address(string_struct_addr, go_bin.get_pointer_size()*2*i);
123+
around_str_addr=go_bin.get_address(string_struct_addr, go_bin.get_pointer_size()*1*i);
120124
around_str=go_bin.read_string_struct(around_str_addr, go_bin.get_pointer_size());
121125
} catch (BinaryAccessException | InvalidBinaryStructureException e) {
122126
continue;
@@ -128,8 +132,7 @@ private boolean is_sys_the_version_string_struct(Address string_struct_addr, Str
128132
badmorestackgsignalMsg=true;
129133
}
130134
}
131-
GolangVersion go_version=new GolangVersion(sys_the_version);
132-
if(go_version.ge("go1.8beta1") && (!badmorestackg0Msg || !badmorestackgsignalMsg)) {
135+
if(!badmorestackg0Msg || !badmorestackgsignalMsg) {
133136
return false;
134137
}
135138

0 commit comments

Comments
 (0)