fixed left and substr input validation, and inet address tostring