Пример #1
0
void sstdata_open(sst_data_t* sstdata)
{
	int ret;
	int id;
	int i;
	int filterlen = 0;

	struct _stat info;
	_stat(sstdata->filename, &info);
	if(info.st_size <12)
	{
		sstdata->key_num = 0;
		__INFO("file content error:%s",sstdata->filename);
	}
	else
	{
		sstdata->file = fopen(sstdata->filename,"rb");
		ret = fread(buffer_detach(sstdata->buf),12,1,sstdata->file);
		sstdata->buf->NUL = 16;
		id = buffer_getint(sstdata->buf);
		sstdata->key_num = buffer_getint(sstdata->buf);
		sstdata->max = buffer_getint(sstdata->buf);

		if(sstdata->id != id)
		{
			__INFO("file content id:%d not equal read id:%d",sstdata->id,id);
		}
		if(info.st_size - 12 > sstdata->buf->buflen)
		{
			buffer_free(sstdata->buf);
			sstdata->buf = buffer_new(info.st_size - 12);
		}

		buffer_clear(sstdata->buf);
		buffer_seekfirst(sstdata->buf);
		fseek(sstdata->file,12+filterlen,SEEK_SET);
		ret = fread(buffer_detach(sstdata->buf),1,info.st_size - 12 - filterlen,sstdata->file);

		i = sstdata->key_num;
		sstdata->keys = (data_t*)xmalloc(sstdata->key_num * sizeof(data_t*));
		for (i=0; i<sstdata->key_num; i++)
		{
			sstdata->keys[i] = buffer_getdata(sstdata->buf);
		}

		sstdata->bigest_key = sstdata->keys[sstdata->key_num-1];
		sstdata->smallest_key = sstdata->keys[0];
	}
}
Пример #2
0
int
ssh_get_num_identities(AuthenticationConnection *auth, int version)
{
	int type, code1 = 0, code2 = 0;
	Buffer request;

	switch (version) {
	case 1:
		code1 = SSH_AGENTC_REQUEST_RSA_IDENTITIES;
		code2 = SSH_AGENT_RSA_IDENTITIES_ANSWER;
		break;
	case 2:
		code1 = SSH2_AGENTC_REQUEST_IDENTITIES;
		code2 = SSH2_AGENT_IDENTITIES_ANSWER;
		break;
	default:
		return 0;
	}

	/*
	 * Send a message to the agent requesting for a list of the
	 * identities it can represent.
	 */
	buffer_init(&request);
	buffer_put_char(&request, code1);

	buffer_clear(&auth->identities);
	if (ssh_request_reply(auth, &request, &auth->identities) == 0) {
		buffer_free(&request);
		return 0;
	}
	buffer_free(&request);

	/* Get message type, and verify that we got a proper answer. */
	type = buffer_get_char(&auth->identities);
	if (agent_failed(type)) {
		return 0;
	} else if (type != code2) {
		fatal("Bad authentication reply message type: %d", type);
	}

	/* Get the number of entries in the response and check it for sanity. */
	auth->howmany = buffer_get_int(&auth->identities);
	if ((u_int)auth->howmany > 1024)
		fatal("Too many identities in authentication reply: %d",
		    auth->howmany);

	return auth->howmany;
}
Пример #3
0
int
mm_answer_pty_cleanup(int sock, Buffer *m)
{
	Session *s;
	char *tty;

	debug3("%s entering", __func__);

	tty = buffer_get_string(m, NULL);
	if ((s = session_by_tty(tty)) != NULL)
		mm_session_close(s);
	buffer_clear(m);
	xfree(tty);
	return (0);
}
Пример #4
0
void free_connection(connection_t *c) {
	if(!c)
		return;

	sptps_stop(&c->sptps);
	ecdsa_free(c->ecdsa);

	buffer_clear(&c->inbuf);
	buffer_clear(&c->outbuf);

	if(c->io.cb)
		abort();

	if(c->socket > 0)
		closesocket(c->socket);

	free(c->name);
	free(c->hostname);

	if(c->config_tree)
		exit_configuration(&c->config_tree);

	free(c);
}
Пример #5
0
static void buffer_tidy(buffer_t *self)
{
	if (buffer_len(self) == 0)
		buffer_clear(self);
	else
	{
		int total = self->node->endp - (char *)self->node - APR_MEMNODE_T_SIZE;
		if (self->offset > (total + 1)/2)
		{
			memcpy((char *)self->node - APR_MEMNODE_T_SIZE, buffer_ptr(self), buffer_len(self));
			self->node->first_avail -= self->offset;
			self->offset = 0;
		}
	}
}
int main(void) {
	sodium_init();

	int status;
	//create random chain key
	buffer_t *chain_key = buffer_create(crypto_auth_BYTES, crypto_auth_BYTES);
	status = buffer_fill_random(chain_key, chain_key->buffer_length);
	if (status != 0) {
		fprintf(stderr, "ERROR: Failed to create chain key. (%i)\n", status);
		buffer_clear(chain_key);
		return status;
	}

	//print first chain key
	printf("Chain key (%zi Bytes):\n", chain_key->content_length);
	print_hex(chain_key);
	putchar('\n');

	//derive message key from chain key
	buffer_t *message_key = buffer_create(crypto_auth_BYTES, crypto_auth_BYTES);
	status = derive_message_key(message_key, chain_key);
	buffer_clear(chain_key);
	if (status != 0) {
		fprintf(stderr, "ERROR: Failed to derive message key. (%i)\n", status);
		buffer_clear(message_key);
		return status;
	}

	//print message key
	printf("Message key (%zi Bytes):\n", message_key->content_length);
	print_hex(message_key);
	putchar('\n');

	buffer_clear(message_key);
	return EXIT_SUCCESS;
}
Пример #7
0
int
mm_answer_rsa_keyallowed(int sock, Buffer *m)
{
	BIGNUM *client_n;
	Key *key = NULL;
	u_char *blob = NULL;
	u_int blen = 0;
	int allowed = 0;

	debug3("%s entering", __func__);

	auth_method = "rsa";
	if (options.rsa_authentication && authctxt->valid) {
		if ((client_n = BN_new()) == NULL)
			fatal("%s: BN_new", __func__);
		buffer_get_bignum2(m, client_n);
		allowed = auth_rsa_key_allowed(authctxt->pw, client_n, &key);
		BN_clear_free(client_n);
	}
	buffer_clear(m);
	buffer_put_int(m, allowed);
	buffer_put_int(m, forced_command != NULL);

	/* clear temporarily storage (used by generate challenge) */
	monitor_reset_key_state();

	if (allowed && key != NULL) {
		key->type = KEY_RSA;	/* cheat for key_to_blob */
		if (key_to_blob(key, &blob, &blen) == 0)
			fatal("%s: key_to_blob failed", __func__);
		buffer_put_string(m, blob, blen);

		/* Save temporarily for comparison in verify */
		key_blob = blob;
		key_bloblen = blen;
		key_blobtype = MM_RSAUSERKEY;
	}
	if (key != NULL)
		key_free(key);

	mm_append_debug(m);

	mm_request_send(sock, MONITOR_ANS_RSAKEYALLOWED, m);

	monitor_permit(mon_dispatch, MONITOR_REQ_RSACHALLENGE, allowed);
	monitor_permit(mon_dispatch, MONITOR_REQ_RSARESPONSE, 0);
	return (0);
}
/* Display a menu showing available games, allowing the user to select what to play */
uint8_t game_menu() {
	int8_t menu_item = SKETCH_GAME_SELECT;
	int8_t prev_menu_item = menu_item;
		
	uint8_t sketch_string_length = strlen(sketch_game_string);
	uint8_t snake_string_length = strlen(snake_game_string);
	uint8_t life_string_length = strlen(life_game_string);
	
	// Draw game list
	buffer_clear(MENU_BUFFER);
	draw_string(MENU_STRINGS_COLUMN, MENU_START_PAGE, sketch_game_string, sketch_string_length, MENU_BUFFER);
	draw_string(MENU_STRINGS_COLUMN, MENU_START_PAGE+1, snake_game_string, snake_string_length, MENU_BUFFER);
	draw_string(MENU_STRINGS_COLUMN, MENU_START_PAGE+2, life_game_string, life_string_length, MENU_BUFFER);
	draw4x4_square(MENU_STRINGS_COLUMN/2, (menu_item + 1) * PAGE_HEIGHT, MENU_BUFFER); // Start selection at sketch
	send_buffer_all(MENU_BUFFER);
		
	// Get input from the user
	uint8_t button_timer = 0;
	while(1) {
		if(button_timer > BUTTON_TIMER_COUNT) {
			// Input for moving up and down menu
			if(BUTTON_UP) menu_item--;
			if(BUTTON_DOWN) menu_item++;
			// Input for selected current game
			if(BUTTON_A1) break;
			button_timer = 0;
		}
		button_timer++;
		
		if(menu_item >= NUM_MENU_ITEMS) menu_item = 0;
		if(menu_item < 0) menu_item = NUM_MENU_ITEMS - 1;

		// Remove the previous square
		// Only need to clear if the menu selection has moved
		if(!(prev_menu_item == menu_item)) {
			clear4x4_square(MENU_STRINGS_COLUMN/2, (prev_menu_item + 1) * PAGE_HEIGHT, MENU_BUFFER);
			
			// Draw dot next to current menu item
			// Center of dot at game_strings_column/2
			draw4x4_square(MENU_STRINGS_COLUMN/2, (menu_item + 1) * PAGE_HEIGHT, MENU_BUFFER);
		}
		
		send_buffer_all(MENU_BUFFER);
		prev_menu_item = menu_item;
	}
	
	return menu_item;
}
Пример #9
0
int
mm_answer_sign(int sock, Buffer *m)
{
	Key *key;
	u_char *p;
	u_char *signature;
	u_int siglen, datlen;
	int keyid;

	debug3("%s", __func__);

	keyid = buffer_get_int(m);
	p = buffer_get_string(m, &datlen);

	/*
	 * Supported KEX types will only return SHA1 (20 byte) or
	 * SHA256 (32 byte) hashes
	 */
	if (datlen != 20 && datlen != 32)
		fatal("%s: data length incorrect: %u", __func__, datlen);

	/* save session id, it will be passed on the first call */
	if (session_id2_len == 0) {
		session_id2_len = datlen;
		session_id2 = xmalloc(session_id2_len);
		memcpy(session_id2, p, session_id2_len);
	}

	if ((key = get_hostkey_by_index(keyid)) == NULL)
		fatal("%s: no hostkey from index %d", __func__, keyid);
	if (key_sign(key, &signature, &siglen, p, datlen) < 0)
		fatal("%s: key_sign failed", __func__);

	debug3("%s: signature %p(%u)", __func__, signature, siglen);

	buffer_clear(m);
	buffer_put_string(m, signature, siglen);

	xfree(p);
	xfree(signature);

	mm_request_send(sock, MONITOR_ANS_SIGN, m);

	/* Turn on permissions for getpwnam */
	monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);

	return (0);
}
Пример #10
0
void coretemp(buffer_t *buf) {
	FILE *f;
	int temp;
	unsigned int hi;

	if(!(f = fopen(CPU_TEMP0, "r"))) {
		buffer_clear(buf);
		return;
	}
	fscanf(f, "%d", &temp);
	fclose(f);

	temp /= 1000;
	hi = (temp >= TEMP_HI);
	buffer_printf(buf, hi ? TEMP_HI_FMT : TEMP_FMT, temp);
}
Пример #11
0
void
_wavpack_skip(wvpinfo *wvp, uint32_t size)
{
  if ( buffer_len(wvp->buf) >= size ) {
    //buffer_dump(mp4->buf, size);
    buffer_consume(wvp->buf, size);
    
    DEBUG_TRACE("  skipped buffer data size %d\n", size);
  }
  else {
    PerlIO_seek(wvp->infile, size - buffer_len(wvp->buf), SEEK_CUR);
    buffer_clear(wvp->buf);
    
    DEBUG_TRACE("  seeked past %d bytes to %d\n", size, (int)PerlIO_tell(wvp->infile));
  }
}
Пример #12
0
static void
send_read_request(int fd_out, u_int id, u_int64_t offset, u_int len,
    char *handle, u_int handle_len)
{
	Buffer msg;

	buffer_init(&msg);
	buffer_clear(&msg);
	buffer_put_char(&msg, SSH2_FXP_READ);
	buffer_put_int(&msg, id);
	buffer_put_string(&msg, handle, handle_len);
	buffer_put_int64(&msg, offset);
	buffer_put_int(&msg, len);
	send_msg(fd_out, &msg);
	buffer_free(&msg);
}
Пример #13
0
static int
ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply)
{
	u_int l, len;
	char buf[1024];

	/* Get the length of the message, and format it in the buffer. */
	len = buffer_len(request);
	put_u32(buf, len);

	/* Send the length and then the packet to the agent. */
	if (atomicio(vwrite, auth->fd, buf, 4) != 4 ||
	    atomicio(vwrite, auth->fd, buffer_ptr(request),
	    buffer_len(request)) != buffer_len(request)) {
		error("Error writing to authentication socket.");
		return 0;
	}
	/*
	 * Wait for response from the agent.  First read the length of the
	 * response packet.
	 */
	if (atomicio(read, auth->fd, buf, 4) != 4) {
	    error("Error reading response length from authentication socket.");
	    return 0;
	}

	/* Extract the length, and check it for sanity. */
	len = get_u32(buf);
	if (len > 256 * 1024)
		fatal("Authentication response too long: %u", len);

	/* Read the rest of the response in to the buffer. */
	buffer_clear(reply);
	while (len > 0) {
		l = len;
		if (l > sizeof(buf))
			l = sizeof(buf);
		if (atomicio(read, auth->fd, buf, l) != l) {
			error("Error reading response from authentication socket.");
			return 0;
		}
		buffer_append(reply, buf, l);
		len -= l;
	}
	return 1;
}
Пример #14
0
int
xfrd_udp_read_packet(buffer_type* packet, int fd)
{
	ssize_t received;

	/* read the data */
	buffer_clear(packet);
	received = recvfrom(fd, buffer_begin(packet), buffer_remaining(packet),
		0, NULL, NULL);
	if(received == -1) {
		log_msg(LOG_ERR, "xfrd: recvfrom failed: %s",
			strerror(errno));
		return 0;
	}
	buffer_set_limit(packet, received);
	return 1;
}
Пример #15
0
/**
 * Error.
 *
 */
static query_state
query_error(query_type* q, ldns_pkt_rcode rcode)
{
    size_t limit = 0;
    if (!q) {
        return QUERY_DISCARDED;
    }
    limit = buffer_limit(q->buffer);
    buffer_clear(q->buffer);
    buffer_pkt_set_qr(q->buffer);
    buffer_pkt_set_rcode(q->buffer, rcode);
    buffer_pkt_set_ancount(q->buffer, 0);
    buffer_pkt_set_nscount(q->buffer, 0);
    buffer_pkt_set_arcount(q->buffer, 0);
    buffer_set_position(q->buffer, limit);
    return QUERY_PROCESSED;
}
Пример #16
0
char *mm_auth2_read_banner(void)
{
	Buffer m;
	char *banner;

	debug3("%s entering", __func__);

	buffer_init(&m);
	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTH2_READ_BANNER, &m);
	buffer_clear(&m);

	mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUTH2_READ_BANNER, &m);
	banner = buffer_get_string(&m, NULL);
	buffer_free(&m);

	return (banner);
}
Пример #17
0
  int Reader::skip_next() {
    int skipped = 0;

    if (buff_written == 0) {
      skipped = buffer_next();
      if (skipped == -1) {
        return -1;
      }
    } else {
      skipped = buff_written;
    }

    //cerr << "SKIP " << buff << endl;
    buffer_clear();

    return skipped;
  }
Пример #18
0
void init_validation() {
    int i;
	vs.type = TRANSACTION_SUBMIT;
    vs.ST = 0;
    vs.abort_count = 0;
    vs.commit_count = 0;
	vs.update_set_count = 0;
    vs.ws = bloom_new(BIG_BLOOM);
    vs.snapshots = DB_MALLOC(sizeof(bloom*) * MaxPreviousST);
    for (i = 0; i < MaxPreviousST; i++)
        vs.snapshots[i] = bloom_new(BIG_BLOOM);
    vs.abort_tr_ids = DB_MALLOC(sizeof(tr_id) * MAX_ABORT_COUNT);
    vs.commit_tr_ids = DB_MALLOC(sizeof(tr_id) * ValidationBufferSize);
    us_buffer = DB_MALLOC(sizeof(buffer));
    us_buffer->data = DB_MALLOC(1024*1024);
    buffer_clear(us_buffer);
}
Пример #19
0
//write sstable data in file
void sstdata_writedata(sst_data_t* sstdata)
{
	int ret,i;
	
	for (i=0; i<sstdata->key_num; i++)
	{
		buffer_putdata(sstdata->buf,sstdata->keys[i]);
		if (sstdata->buf->NUL > 8192)
		{
			ret = fwrite(buffer_detach(sstdata->buf),sstdata->buf->NUL,1,sstdata->file);
			buffer_clear(sstdata->buf);
		}
	}

	ret = fwrite(buffer_detach(sstdata->buf),sstdata->buf->NUL,1,sstdata->file);
	fflush(sstdata->file);
}
Пример #20
0
int sstdata_compactput( sst_data_t* sstdata,data_t* data )
{
	int ret;
	if(sstdata->max > sstdata->key_num)
	{
		buffer_clear(sstdata->buf);
		buffer_putdata(sstdata->buf,data);
		ret = fwrite(buffer_detach(sstdata->buf),sstdata->buf->NUL,1,sstdata->file);
		sstdata->key_num++;
		return 0;
	}
	else
	{
		__INFO("file is full");
		return 1;
	}
}
Пример #21
0
void message_destroy( struct message * self )
{
    if ( self->tolist )
    {
        sidlist_destroy( self->tolist );
        self->tolist = NULL;
    }

//     if ( self->failurelist )
//     {
//         sidlist_destroy( self->failurelist );
//         self->failurelist = NULL;
//     }

    buffer_clear( &self->buffer );
    free( self );
}
Пример #22
0
int inline_data_receive(char *data,int length) {

  if(processing_png == true) {
    if(file_end==1) {processing_png=false; return 1;}
    char decoded_buffer[10240]; // should be malloc'd based on length.
    bool failflag;
    int decoded_buffer_size = base64_decode(data,length,decoded_buffer,&failflag);
 
    if(decoded_buffer_size != 0) {
      inlinepng_process_data(decoded_buffer,decoded_buffer_size);
      if(file_end==1) { processing_png=false; return 1; }
    }

    if(failflag == true) {
      file_end =1;
      processing_png=false;
      return 2;
    }
    if(file_end==1) processing_png=false;
    return 1;
  }

  file_end=0;
  buffer_push(data,length);
  int pos = buffer_search(inline_magic);

  if(pos < 0) return 0;

  processing_png=true;

  base64_init();
  initialize_png_reader();
  char decoded_buffer[4096]; // should be malloc'd based on length.
  bool failflag;
  int decoded_buffer_size = base64_decode(buffer+pos+strlen(inline_magic),buffer_size-pos-strlen(inline_magic),decoded_buffer,&failflag);
  if(decoded_buffer_size != 0) {
    inlinepng_process_data(decoded_buffer,decoded_buffer_size);
  }
  buffer_clear();

  if(failflag) {
    processing_png=false;
    return 0;
  }
  return 2;
}
Пример #23
0
static int
monitor_read_log(struct monitor *pmonitor)
{
	Buffer logmsg;
	u_int len, level;
	char *msg;

	buffer_init(&logmsg);

	/* Read length */
	buffer_append_space(&logmsg, 4);
	if (atomicio(read, pmonitor->m_log_recvfd,
	    buffer_ptr(&logmsg), buffer_len(&logmsg)) != buffer_len(&logmsg)) {
		if (errno == EPIPE) {
			buffer_free(&logmsg);
			debug("%s: child log fd closed", __func__);
			close(pmonitor->m_log_recvfd);
			pmonitor->m_log_recvfd = -1;
			return -1;
		}
		fatal("%s: log fd read: %s", __func__, strerror(errno));
	}
	len = buffer_get_int(&logmsg);
	if (len <= 4 || len > 8192)
		fatal("%s: invalid log message length %u", __func__, len);

	/* Read severity, message */
	buffer_clear(&logmsg);
	buffer_append_space(&logmsg, len);
	if (atomicio(read, pmonitor->m_log_recvfd,
	    buffer_ptr(&logmsg), buffer_len(&logmsg)) != buffer_len(&logmsg))
		fatal("%s: log fd read: %s", __func__, strerror(errno));

	/* Log it */
	level = buffer_get_int(&logmsg);
	msg = buffer_get_string(&logmsg, NULL);
	if (log_level_name(level) == NULL)
		fatal("%s: invalid log level %u (corrupted message?)",
		    __func__, level);
	do_log2(level, "%s [preauth]", msg);

	buffer_free(&logmsg);
	free(msg);

	return 0;
}
Пример #24
0
/* put algorithm proposal into buffer */
static void
kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
{
	int i;

	buffer_clear(b);
	/*
	 * add a dummy cookie, the cookie will be overwritten by
	 * kex_send_kexinit(), each time a kexinit is set
	 */
	for (i = 0; i < KEX_COOKIE_LEN; i++)
		buffer_put_char(b, 0);
	for (i = 0; i < PROPOSAL_MAX; i++)
		buffer_put_cstring(b, proposal[i]);
	buffer_put_char(b, 0);			/* first_kex_packet_follows */
	buffer_put_int(b, 0);			/* uint32 reserved */
}
Пример #25
0
void reset_validation_buffer() {
    int i;
    bloom* tmp;
    
    vs.abort_count = 0;
    vs.commit_count = 0;
	vs.update_set_count = 0;
    
    tmp = vs.ws; 
    vs.ws = vs.snapshots[MaxPreviousST-1];
    bloom_clear(vs.ws);
    for (i = MaxPreviousST-1; i > 0; i--)
        vs.snapshots[i] = vs.snapshots[i-1];
    vs.snapshots[0] = tmp;

	buffer_clear(us_buffer);
}
Пример #26
0
struct shaft_conn *
do_init(int fd_in, int fd_out, struct shaft_flow *flow)
{
	u_int type, version;
	Buffer msg;
	struct shaft_conn *ret;

	buffer_init(&msg);
	buffer_put_char(&msg, SHAFT_INIT);
	buffer_put_int(&msg, SHAFT_VERSION);
	buffer_put_cstring(&msg, flow->local);
	send_msg(fd_out, &msg);

	buffer_clear(&msg);

	get_msg(fd_in, &msg);

	/* Expecting a VERSION reply */
	if ((type = buffer_get_char(&msg)) != SHAFT_VERSION) {
		error("Invalid packet back from SHAFT_INIT (type %u)",
		    version);
		buffer_free(&msg);
		return(NULL);
	}
	version = buffer_get_int(&msg);
	flow->dst = buffer_get_cstring(&msg, NULL);
	if (flow->dst == NULL) {
		error("Invalid packet back from SHAFT_INIT remote addr is null");
		buffer_free(&msg);
		return(NULL);
	}

	debug2("Remote version: %u", version);
	debug2("Remote Address: %s", flow->dst);

	buffer_free(&msg);

	ret = xmalloc(sizeof(*ret));
	ret->fd_in = fd_in;
	ret->fd_out = fd_out;
	ret->version = version;
	ret->msg_id = 1;

	return(ret);
}
Пример #27
0
  bool Reader::overlap_from_buff(Overlap** overlap, const ReadSet& reads) {
    if (buff_written == 0) {
      return false;
    }

    if (strncmp(buff, "{OVL", 4) != 0) {
      return false;
    }

    int a_id, b_id, score, a_hang, b_hang;
    char adjacency;

    // use buffer marks to create an overlap from buffer
    for (auto& mark: buff_marks) {
      if (mark.type != AttrDef) {
        continue;
      }

      // temporary terminate the string so we can use sscanf
      char tmp = buff[mark.hi];
      buff[mark.hi] = 0;

      if (sscanf(buff + mark.lo, "rds:%u, %u", &a_id, &b_id)) {
        // just skip other branches
      } else if (sscanf(buff + mark.lo, "adj:%c", &adjacency)) {
        // just skip other branches
      } else if (sscanf(buff + mark.lo, "scr:%d", &score)) {
        // just skip other branches
      } else if (sscanf(buff + mark.lo, "ahg:%d", &a_hang)) {
        // just skip other branches
      } else if (sscanf(buff + mark.lo, "bhg:%d", &b_hang)) {
        // just skip other branches
      }

      // return the right character back
      buff[mark.hi] = tmp;
    }

    buffer_clear();

    *overlap = new Overlap(reads[a_id], a_hang, reads[b_id], b_hang,
        adjacency == 'I' ? true : false);

    return true;
  }
Пример #28
0
int
mm_answer_gss_userok(int sock, Buffer *m)
{
	int authenticated;

	authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);

	buffer_clear(m);
	buffer_put_int(m, authenticated);

	debug3("%s: sending result %d", __func__, authenticated);
	mm_request_send(sock, MONITOR_ANS_GSSUSEROK, m);

	auth_method = "gssapi-with-mic";

	/* Monitor loop will terminate if authenticated */
	return (authenticated);
}
Пример #29
0
int
mm_answer_pam_init_ctx(int sock, Buffer *m)
{

	debug3("%s", __func__);
	authctxt->user = buffer_get_string(m, NULL);
	sshpam_ctxt = (sshpam_device.init_ctx)(authctxt);
	sshpam_authok = NULL;
	buffer_clear(m);
	if (sshpam_ctxt != NULL) {
		monitor_permit(mon_dispatch, MONITOR_REQ_PAM_FREE_CTX, 1);
		buffer_put_int(m, 1);
	} else {
		buffer_put_int(m, 0);
	}
	mm_request_send(sock, MONITOR_ANS_PAM_INIT_CTX, m);
	return (0);
}
Пример #30
0
static void
chan_send_oclose1(Channel *c)
{
	debug2("channel %d: send oclose", c->self);
	switch (c->ostate) {
	case CHAN_OUTPUT_OPEN:
	case CHAN_OUTPUT_WAIT_DRAIN:
		buffer_clear(&c->output);
		packet_start(SSH_MSG_CHANNEL_OUTPUT_CLOSE);
		packet_put_int(c->remote_id);
		packet_send();
		break;
	default:
		error("channel %d: cannot send oclose for ostate %d",
		    c->self, c->ostate);
		break;
	}
}