Fix overflow in cmd_write.c and issue in shlr/java