*
* Citadel/UX client/server IPC - client module using TCP/IP
*
- * version 1.3
+ * version 1.3 $Id$
*
*/
* convert service and host entries into a six-byte numeric in the format
* expected by a SOCKS v4 server
*/
-void numericize(unsigned char *buf, char *host, char *service, char *protocol)
+void numericize(char *buf, char *host, char *service, char *protocol)
{
struct hostent *phe;
struct servent *pse;
*/
void serv_gets(char *buf)
{
- buf[0] = 0;
- do {
- buf[strlen(buf) + 1] = 0;
- if (strlen(buf) < 255) serv_read(&buf[strlen(buf)], 1);
- } while (buf[strlen(buf)-1] != 10);
- if (strlen(buf) > 0) buf[strlen(buf)-1] = 0;
- /* printf("> %s\n", buf); */
+ int i;
+
+ /* Read one character at a time.
+ */
+ for (i = 0;;i++) {
+ serv_read(&buf[i], 1);
+ if (buf[i] == '\n' || i == 255)
+ break;
+ }
+
+ /* If we got a long line, discard characters until the newline.
+ */
+ if (i == 255)
+ while (buf[i] != '\n')
+ serv_read(&buf[i], 1);
+
+ /* Strip the trailing newline.
+ */
+ buf[i] = 0;
}
char cithost[256]; int host_copied = 0;
char citport[256]; int port_copied = 0;
char socks4[256];
- unsigned char buf[256];
+ char buf[256];
struct passwd *p;
strcpy(cithost,DEFAULT_HOST); /* default host */
printf("Attaching to server...\r");
fflush(stdout);
- sprintf(buf,"%c%c",
+ snprintf(buf,sizeof buf,"%c%c",
4, /* version 4 */
1); /* method = connect */
serv_write(buf,2);