Changeset a2fadb4 in code
- Timestamp:
- Mar 7, 2014, 3:21:30 PM (11 years ago)
- Branches:
- master
- Children:
- 8871953
- Parents:
- 270fd23
- git-author:
- Mike Belopuhov <mike@…> (03/07/14 15:17:23)
- git-committer:
- Mike Belopuhov <mike@…> (03/07/14 15:21:30)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
icb.c
r270fd23 ra2fadb4 82 82 83 83 is->last = getmonotime(); 84 type = msg[ 1];85 msg += 2;84 type = msg[0]; 85 msg++; 86 86 if (!ISSETF(is->flags, ICB_SF_LOGGEDIN) && type != ICB_M_LOGIN) { 87 87 icb_error(is, "Not logged in"); … … 378 378 const char *fmt, ...) 379 379 { 380 char buf[ICB_MSGSIZE ];380 char buf[ICB_MSGSIZE - 10]; /* truncate to make sure all fits */ 381 381 va_list ap; 382 382 struct icb_session *s; … … 481 481 icb_dowho(struct icb_session *is, struct icb_group *ig) 482 482 { 483 char buf[ICB_MSGSIZE ];483 char buf[ICB_MSGSIZE - 10]; /* truncate to make sure all fits */ 484 484 struct icb_session *s; 485 485 int nusers = 0; … … 510 510 icb_who(struct icb_session *is, struct icb_group *ig) 511 511 { 512 char buf[ICB_MSGSIZE ];512 char buf[ICB_MSGSIZE - 10]; /* truncate to make sure all fits */ 513 513 struct icb_group *g; 514 514 -
icb.h
r270fd23 ra2fadb4 18 18 #include <sys/tree.h> 19 19 20 /* 21 * ICB packet has the following format: <length><type><data> 22 * <lenght> is one byte length of the packet excluding the <lenght> byte; 23 * <type> is one byte type of the packet; 24 * <data> might not be null-terminated. 25 */ 20 26 #define ICB_MSGSIZE 256 21 27 … … 71 77 char client[ICB_MAXNICKLEN]; 72 78 char host[MAXHOSTNAMELEN]; 73 char buffer[ICB_MSGSIZE +1];79 char buffer[ICB_MSGSIZE]; 74 80 struct event ev; 75 81 struct bufferevent *bev; -
icbd.c
r270fd23 ra2fadb4 378 378 { 379 379 struct icb_session *is = (struct icb_session *)arg; 380 unsigned char length; 380 381 381 382 while (EVBUFFER_LENGTH(EVBUFFER_INPUT(bev)) > 0) { 382 383 if (is->length == 0) { 383 384 /* read length */ 384 is->rlen = bufferevent_read(bev, is->buffer, 1); 385 is->length = (size_t)(unsigned char)is->buffer[0]; 386 if (is->length == 0) { 385 bufferevent_read(bev, &length, 1); 386 if (length == 0) { 387 /* 388 * An extension has been proposed: 389 * if length is 0, the packet is part of an 390 * "extended packet". The packet should be 391 * treated as if length was 255 and the next 392 * packet received from the sender should be 393 * appended to this packet. 394 * 395 * This server doesn't support this yet. 396 */ 387 397 icbd_drop(is, "invalid packet"); 388 398 return; 389 399 } 400 is->length = (size_t)length; 401 is->rlen = 0; 390 402 } 391 403 /* read as much as we can */ … … 406 418 if (is->rlen < is->length) 407 419 return; 420 /* null-terminate the data */ 421 is->buffer[MIN(is->rlen, ICB_MSGSIZE - 1)] = '\0'; 408 422 /* process the message in full */ 409 423 icb_input(is); -
logger.c
r270fd23 ra2fadb4 197 197 return; 198 198 /* terminate the buffer */ 199 m[MIN(nread - sizeof *e, ICB_MSGSIZE )] = '\0';199 m[MIN(nread - sizeof *e, ICB_MSGSIZE - 1)] = '\0'; 200 200 /* find the appropriate log file */ 201 201 for (i = 0; i < nlogfiles; i++)
Note:
See TracChangeset
for help on using the changeset viewer.