Example #1
0
static int
fc_read_result(ftp_connection_t *fc, char *buf, size_t buflen)
{
  char resp[1024];
  char *end;
  int rc;

  do {
    if(ftp_read_line(fc, resp, sizeof(resp)) < 0)
      return -1;

    rc = strtol(resp, &end, 10);
  } while(*end == '-');

  const char *msg = strchr(resp, ' ');
  if(msg != NULL)
    msg++;

  if(buf != NULL && buflen) {
    if(msg != NULL) {
      snprintf(buf, buflen, "%s", msg);
    } else {
      *buf = 0;
    }
  }

  if(rc == 412) {
    TRACE(TRACE_ERROR, "FTP", "Disconnected: %s", msg ?: "<no reason>");
    return -1;
  }
Example #2
0
File: ftp.c Project: brl/ftpscan
int
ftp_command_response(int fd)
{
	char *response = ftp_read_line(fd);
	debug("<-- %s", response);
	set_last_message(response);
	return response2code(response);

}
Example #3
0
File: ftp.c Project: brl/ftpscan
static char *
ftp_read_line_timeout(int fd, int timeout)
{
	struct pollfd pfd;

	pfd.fd = fd;
	pfd.events = POLLIN;
	pfd.revents = 0;

	if(poll(&pfd, 1, timeout) == 0)
		return NULL;
	if((pfd.revents & POLLIN) == 0)
		return NULL;

	return ftp_read_line(fd);
}