Changes in lib/misc.c [0e788f5:e252d8c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r0e788f5 re252d8c 420 420 void random_bytes( unsigned char *buf, int count ) 421 421 { 422 #ifndef _WIN32423 422 static int use_dev = -1; 424 423 … … 470 469 471 470 if( !use_dev ) 472 #endif473 471 { 474 472 int i; … … 525 523 ns_msg nsh; 526 524 ns_rr rr; 527 int i,n, len, size;525 int n, len, size; 528 526 529 527 g_snprintf( name, sizeof( name ), "_%s._%s.%s", service, protocol, domain ); … … 538 536 while( ns_parserr( &nsh, ns_s_an, n, &rr ) == 0 ) 539 537 { 540 size = ns_rr_rdlen( rr ); 538 char name[NS_MAXDNAME]; 539 540 if( ns_rr_rdlen( rr ) < 7) 541 break; 542 541 543 buf = ns_rr_rdata( rr ); 542 544 543 len = 0; 544 for( i = 6; i < size && buf[i]; i += buf[i] + 1 ) 545 len += buf[i] + 1; 546 547 if( i > size ) 545 if( dn_expand(querybuf, querybuf + size, &buf[6], name, NS_MAXDNAME) == -1 ) 548 546 break; 547 548 len = strlen(name) + 1; 549 549 550 550 reply = g_malloc( sizeof( struct ns_srv_reply ) + len ); 551 memcpy( reply->name, buf + 7, len ); 552 553 for( i = buf[6]; i < len && buf[7+i]; i += buf[7+i] + 1 ) 554 reply->name[i] = '.'; 555 556 if( i > len ) 557 { 558 g_free( reply ); 559 break; 560 } 551 memcpy( reply->name, name, len ); 561 552 562 553 reply->prio = ( buf[0] << 8 ) | buf[1]; … … 682 673 white\ space in 'various ways'. Returns a NULL-terminated static 683 674 char** so watch out with nested use! Definitely not thread-safe. */ 684 char **split_command_parts( char *command )675 char **split_command_parts( char *command, int limit ) 685 676 { 686 677 static char *cmd[IRC_MAX_ARGS+1]; … … 692 683 k = 1; 693 684 for( s = command; *s && k < IRC_MAX_ARGS; s ++ ) 685 { 694 686 if( *s == ' ' && !q ) 695 687 { 696 688 *s = 0; 697 689 while( *++s == ' ' ); 698 if( *s == '"' || *s == '\'')690 if( k != limit && (*s == '"' || *s == '\'') ) 699 691 { 700 692 q = *s; … … 704 696 { 705 697 cmd[k++] = s; 698 if (limit && k > limit) { 699 break; 700 } 706 701 s --; 707 702 } … … 722 717 q = *s = 0; 723 718 } 719 } 724 720 725 721 /* Full zero-padding for easier argc checking. */
Note: See TracChangeset
for help on using the changeset viewer.