aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-08 21:38:00 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-08 21:38:00 +0000
commit197f413ca268ec9f19a7491573290fe4835fae69 (patch)
tree842f654a37163d9c3b5faa4c76b5e6bcfc778c87 /src/gns/gnunet-gns.c
parent0f08490003a273621af504758fb76fc036786bbf (diff)
downloadgnunet-197f413ca268ec9f19a7491573290fe4835fae69.tar.gz
gnunet-197f413ca268ec9f19a7491573290fe4835fae69.zip
-fix crash if private zone key did not exist
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r--src/gns/gnunet-gns.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 6643317da..aad8cc833 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -211,11 +211,11 @@ run (void *cls, char *const *args, const char *cfgfile,
211 211
212 212
213 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 213 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
214 "PRIVATE_ZONEKEY", &keyfile)) 214 "PRIVATE_ZONEKEY", &keyfile))
215 { 215 {
216 if (!raw) 216 if (!raw)
217 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 217 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
218 "No private zone key found!\n"); 218 "No private zone key file name specified in configuration!\n");
219 shorten_key = NULL; 219 shorten_key = NULL;
220 } 220 }
221 else 221 else
@@ -231,16 +231,28 @@ run (void *cls, char *const *args, const char *cfgfile,
231 if (!raw) 231 if (!raw)
232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
233 "Using private zone: %s!\n", &zonename); 233 "Using private zone: %s!\n", &zonename);
234 }
235 else
236 {
237 /* FIXME: shouldn't we just create the private key in this case? */
238 if (!raw)
239 fprintf (stderr,
240 _("Key file `%s' for private zone does not exist!\n"),
241 keyfile);
234 242
235 } 243 }
236 GNUNET_free(keyfile); 244 GNUNET_free(keyfile);
237 GNUNET_CRYPTO_rsa_key_free (private_key); 245 if (NULL != private_key)
246 {
247 GNUNET_CRYPTO_rsa_key_free (private_key);
248 private_key = NULL;
249 }
238 } 250 }
239 251
240 252
241 gns = GNUNET_GNS_connect (cfg); 253 gns = GNUNET_GNS_connect (cfg);
242 if (lookup_type != NULL) 254 if (NULL != lookup_type)
243 rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); 255 rtype = GNUNET_NAMESTORE_typename_to_number (lookup_type);
244 else 256 else
245 rtype = GNUNET_GNS_RECORD_A; 257 rtype = GNUNET_GNS_RECORD_A;
246 258
@@ -251,9 +263,8 @@ run (void *cls, char *const *args, const char *cfgfile,
251 return; 263 return;
252 } 264 }
253 265
254 if (shorten_name != NULL) 266 if (NULL != shorten_name)
255 { 267 {
256 /** shorten name */
257 GNUNET_GNS_shorten_zone (gns, shorten_name, 268 GNUNET_GNS_shorten_zone (gns, shorten_name,
258 &private_zone, 269 &private_zone,
259 &shorten_zone, 270 &shorten_zone,
@@ -262,7 +273,7 @@ run (void *cls, char *const *args, const char *cfgfile,
262 shorten_name); 273 shorten_name);
263 } 274 }
264 275
265 if (lookup_name != NULL) 276 if (NULL != lookup_name)
266 { 277 {
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
268 "Lookup\n"); 279 "Lookup\n");
@@ -274,7 +285,7 @@ run (void *cls, char *const *args, const char *cfgfile,
274 &process_lookup_result, lookup_name); 285 &process_lookup_result, lookup_name);
275 } 286 }
276 287
277 if (auth_name != NULL) 288 if (NULL != auth_name)
278 { 289 {
279 GNUNET_GNS_get_authority(gns, auth_name, &process_auth_result, auth_name); 290 GNUNET_GNS_get_authority(gns, auth_name, &process_auth_result, auth_name);
280 } 291 }