Download overflow attack; possible upload attack

Download buffer overflow attack; possible infinite loop upload attack
Also fixed buffer overflow vulnerability