Fix buffer overflow bug in read/write

see https://code.google.com/p/junixsocket/issues/detail?id=20
Thanks, Eric Delaunay!