diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 5b36fc380..58d09806b 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -65,6 +65,7 @@ static void | |||
65 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 65 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) |
66 | { | 66 | { |
67 | struct GNUNET_TESTING_Daemon *daemon = cls; | 67 | struct GNUNET_TESTING_Daemon *daemon = cls; |
68 | int msize; | ||
68 | if (daemon == NULL) | 69 | if (daemon == NULL) |
69 | return; | 70 | return; |
70 | 71 | ||
@@ -75,6 +76,11 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
75 | } | 76 | } |
76 | 77 | ||
77 | GNUNET_assert (message != NULL); | 78 | GNUNET_assert (message != NULL); |
79 | msize = ntohs(message->size); | ||
80 | if (msize < 1) | ||
81 | { | ||
82 | return; | ||
83 | } | ||
78 | if (daemon->th != NULL) | 84 | if (daemon->th != NULL) |
79 | { | 85 | { |
80 | GNUNET_TRANSPORT_get_hello_cancel(daemon->th, &process_hello, daemon); | 86 | GNUNET_TRANSPORT_get_hello_cancel(daemon->th, &process_hello, daemon); |
@@ -85,14 +91,18 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
85 | "HELLO", GNUNET_i2s (&daemon->id)); | 91 | "HELLO", GNUNET_i2s (&daemon->id)); |
86 | #endif | 92 | #endif |
87 | 93 | ||
88 | GNUNET_free_non_null(daemon->hello); | ||
89 | daemon->hello = GNUNET_malloc(ntohs(message->size)); | ||
90 | memcpy(daemon->hello, message, ntohs(message->size)); | ||
91 | 94 | ||
92 | if (daemon->th != NULL) | 95 | |
93 | { | 96 | { |
94 | GNUNET_TRANSPORT_disconnect(daemon->th); | 97 | GNUNET_free_non_null(daemon->hello); |
95 | daemon->th = NULL; | 98 | daemon->hello = GNUNET_malloc(msize); |
99 | memcpy(daemon->hello, message, msize); | ||
100 | |||
101 | if (daemon->th != NULL) | ||
102 | { | ||
103 | GNUNET_TRANSPORT_disconnect(daemon->th); | ||
104 | daemon->th = NULL; | ||
105 | } | ||
96 | } | 106 | } |
97 | 107 | ||
98 | } | 108 | } |