aboutsummaryrefslogtreecommitdiff
path: root/src/util/socks.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-10 18:41:46 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-10 18:41:46 +0100
commit81fff5fce44190dd49bf17677e7710ed9d4cc7b6 (patch)
treebc5f8c48f45a096a446abda761ec54cfee273ab5 /src/util/socks.c
parentefd3fc1387bb96d54856810bbdcd3057fefaa296 (diff)
downloadgnunet-81fff5fce44190dd49bf17677e7710ed9d4cc7b6.tar.gz
gnunet-81fff5fce44190dd49bf17677e7710ed9d4cc7b6.zip
fix use of uninitialized value host1 on error logging
Diffstat (limited to 'src/util/socks.c')
-rw-r--r--src/util/socks.c69
1 files changed, 48 insertions, 21 deletions
diff --git a/src/util/socks.c b/src/util/socks.c
index 8c32eff4f..85548fd79 100644
--- a/src/util/socks.c
+++ b/src/util/socks.c
@@ -569,17 +569,25 @@ GNUNET_SOCKS_check_service (const char *service_name,
569 */ 569 */
570struct GNUNET_CONNECTION_Handle * 570struct GNUNET_CONNECTION_Handle *
571GNUNET_SOCKS_do_connect (const char *service_name, 571GNUNET_SOCKS_do_connect (const char *service_name,
572 const struct GNUNET_CONFIGURATION_Handle *cfg) 572 const struct GNUNET_CONFIGURATION_Handle *cfg)
573{ 573{
574 struct GNUNET_SOCKS_Handshake *ih; 574 struct GNUNET_SOCKS_Handshake *ih;
575 struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */ 575 struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
576 char *host0,*host1,*user,*pass; 576 char *host0;
577 unsigned long long port0,port1; 577 char *host1;
578 578 char *user;
579 if (GNUNET_YES != GNUNET_SOCKS_check_service (service_name, cfg)) 579 char *pass;
580 unsigned long long port0;
581 unsigned long long port1;
582
583 if (GNUNET_YES !=
584 GNUNET_SOCKS_check_service (service_name, cfg))
580 return NULL; 585 return NULL;
581 if (GNUNET_OK != 586 if (GNUNET_OK !=
582 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "SOCKSPORT", &port0)) 587 GNUNET_CONFIGURATION_get_value_number (cfg,
588 service_name,
589 "SOCKSPORT",
590 &port0))
583 port0 = 9050; 591 port0 = 9050;
584 /* A typical Tor client should usually try port 9150 for the TBB too, but 592 /* A typical Tor client should usually try port 9150 for the TBB too, but
585 * GNUnet can probably assume a system Tor installation. */ 593 * GNUnet can probably assume a system Tor installation. */
@@ -591,16 +599,23 @@ GNUNET_SOCKS_do_connect (const char *service_name,
591 service_name); 599 service_name);
592 return NULL; 600 return NULL;
593 } 601 }
594 if ((GNUNET_OK != 602 if ( (GNUNET_OK !=
595 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port1)) 603 GNUNET_CONFIGURATION_get_value_number (cfg,
596 || (port1 > 65535) || (port1 <= 0) || 604 service_name,
605 "PORT",
606 &port1)) ||
607 (port1 > 65535) ||
608 (port1 <= 0) ||
597 (GNUNET_OK != 609 (GNUNET_OK !=
598 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME", &host1))) 610 GNUNET_CONFIGURATION_get_value_string (cfg,
611 service_name,
612 "HOSTNAME",
613 &host1)))
599 { 614 {
600 LOG (GNUNET_ERROR_TYPE_WARNING, 615 LOG (GNUNET_ERROR_TYPE_WARNING,
601 _ 616 _("Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
602 ("Attempting to proxy service `%s' to invalid port %d or hostname `%s'.\n"), 617 service_name,
603 service_name,port1,host1); 618 port1);
604 return NULL; 619 return NULL;
605 } 620 }
606 /* Appeared to still work after host0 corrupted, so either test case is broken, or 621 /* Appeared to still work after host0 corrupted, so either test case is broken, or
@@ -608,20 +623,32 @@ GNUNET_SOCKS_do_connect (const char *service_name,
608 if (GNUNET_OK != 623 if (GNUNET_OK !=
609 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0)) 624 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0))
610 host0 = NULL; 625 host0 = NULL;
611 socks5 = GNUNET_CONNECTION_create_from_connect (cfg, (host0 != NULL)? host0:"127.0.0.1", port0); 626 socks5 = GNUNET_CONNECTION_create_from_connect (cfg,
627 (host0 != NULL)
628 ? host0
629 :"127.0.0.1",
630 port0);
612 GNUNET_free_non_null (host0); 631 GNUNET_free_non_null (host0);
613 632
614 /* Sets to NULL if they do not exist */ 633 /* Sets to NULL if they do not exist */
615 (void) GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSUSER", &user); 634 (void) GNUNET_CONFIGURATION_get_value_string (cfg,
616 (void) GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSPASS", &pass); 635 service_name,
636 "SOCKSUSER",
637 &user);
638 (void) GNUNET_CONFIGURATION_get_value_string (cfg,
639 service_name,
640 "SOCKSPASS",
641 &pass);
617 ih = GNUNET_SOCKS_init_handshake(user,pass); 642 ih = GNUNET_SOCKS_init_handshake(user,pass);
618 if (NULL != user) GNUNET_free (user); 643 GNUNET_free_non_null (user);
619 if (NULL != pass) GNUNET_free (pass); 644 GNUNET_free_non_null (pass);
620 645
621 GNUNET_SOCKS_set_handshake_destination (ih,host1,port1); 646 GNUNET_SOCKS_set_handshake_destination (ih,
647 host1,
648 port1);
622 GNUNET_free (host1); 649 GNUNET_free (host1);
623 650 return GNUNET_SOCKS_run_handshake (ih,
624 return GNUNET_SOCKS_run_handshake(ih,socks5); 651 socks5);
625} 652}
626 653
627/* socks.c */ 654/* socks.c */