Revision 534e126a src/net_helper-ml.c

View differences:

src/net_helper-ml.c
619 619
	return remote;
620 620
}
621 621

  
622
const char *node_ip(const struct nodeID *s) {
623
	static char ip[64];
622
int node_ip(const struct nodeID *s, char *ip, int size)
624 623
	int len;
625 624
	char *start, *end;
626
	const char *tmp = node_addr(s);
625
	char tmp[64];
626

  
627
	len = node_addr(s, tmp, 64);
628
	if (len < 0) {
629
		return len;
630
	}
627 631
	start = strstr(tmp, "-") + 1;
628 632
	end = strstr(start, ":");
629 633
	len = end - start;
634
	if (len >= size) {
635
		return -1;
636
	}
630 637
	memcpy(ip, start, len);
631 638
	ip[len] = 0;
632 639

  
633
	return (const char *)ip;
640
	return 1;
634 641
}
635 642

  
636 643

  
......
649 656
}
650 657

  
651 658

  
652
const char *node_addr(const struct nodeID *s)
659
int node_addr(const struct nodeID *s, char *addr, int len)
653 660
{
654
  static char addr[256];
655 661
  // TODO: mlSocketIDToString always return 0 !!!
656
  int r = mlSocketIDToString(s->addr,addr,256);
662
  int r = mlSocketIDToString(s->addr,addr,len);
657 663
  if (!r)
658
	  return addr;
664
	  return 1;
659 665
  else
660
	  return "";
666
	  return -1;
661 667
}
662 668

  
663 669
struct nodeID *nodeid_dup(struct nodeID *s)

Also available in: Unified diff