patch-src_master_c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. $OpenBSD: patch-src_master_c,v 1.3 2017/05/06 17:23:10 naddy Exp $
  2. Index: src/master.c
  3. --- src/master.c.orig
  4. +++ src/master.c
  5. @@ -56,7 +56,7 @@ int init( void )
  6. strcpy( global.node[id]->ipstr, str );
  7. global.node[id]->addr.sin_addr.s_addr = inet_addr(str);
  8. fscanf(fp,"%s\n", str );
  9. - global.node[id]->addr.sin_port = atoi(str);
  10. + global.node[id]->addr.sin_port = htons(atoi(str));
  11. global.node[id]->addr.sin_family = AF_INET;
  12. global.node[id]->socket = socket( AF_INET, SOCK_STREAM, 0 );
  13. }
  14. @@ -132,12 +132,12 @@ char *get_time_str( u_int seconds )
  15. return timestr;
  16. }
  17. -int main( int argc, u_char **argv )
  18. +int main( int argc, char **argv )
  19. {
  20. static unsigned id, init_time;
  21. global.num_nodes = 0;
  22. - if(!commline_handler(argc,argv))
  23. + if(!commline_handler(argc,(u_char **)argv))
  24. clean_up(1);
  25. if(!init())
  26. error("error: could not load %s\n", NODES_FILE );
  27. @@ -147,7 +147,7 @@ int main( int argc, u_char **argv )
  28. {
  29. print_handler("connecting to: %s %d: ",
  30. global.node[id]->ipstr,
  31. - global.node[id]->addr.sin_port );
  32. + ntohs(global.node[id]->addr.sin_port) );
  33. if(!connect_node(id))
  34. print_handler("connect failed.\n");
  35. else
  36. @@ -181,13 +181,13 @@ int main( int argc, u_char **argv )
  37. {
  38. static u_char *pstr;
  39. static u_int len;
  40. - if( pstr = message_handler(netbuf,&len) )
  41. + if( (pstr = message_handler(netbuf,&len)) )
  42. write( global.node[id++]->socket, pstr, len );
  43. else
  44. {
  45. print("closing connection: %s %d.\n",
  46. global.node[id]->ipstr,
  47. - global.node[id]->addr.sin_port );
  48. + ntohs(global.node[id]->addr.sin_port) );
  49. disconnect_node(id);
  50. }
  51. }