Fix Coverity CID #54529: String not NUL terminated

Reserve space for NUL byte and add \0 at end of string so strpbrk()
doesn't go off the fence.

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
Fix Coverity CID #54526: Resource leak

Free ctrl pointer on error.

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
Fix Coverity CID #54525: Array compared against 0

Correct check for invalid/missing FTP username.

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
Fix Coverity CID #54527: Wrong sizeof argument

Nasty invalid sizeof() call to recv(), causing kernel to only read 4/8
bytes (depending on 32/64 bit arch) at a time per read from socket.

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
Coverity fixes for unchecked API return values, close unused sockets on error

- Do memset(0) of stack variables to ensure all members are properly
  initialized to a known value (0) before API cals.
- Check return values of API functions, could otherwise be nasty results
- Should fix Coverity CID #54519, #54520, #54521, #54522, #54524

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>