server: fix potential buffer overrun in socket setup path