diff options
author | t3sserakt <t3ss@posteo.de> | 2021-07-19 19:54:18 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-07-19 20:26:54 +0200 |
commit | 7a1ec37c139263e4ccb056ebf9ab4582923961d2 (patch) | |
tree | df4cfb02e01871e38a335c796039945c700006d4 /src/util | |
parent | 9d7ff3c3fbee189367da05a1517777c76a80b23b (diff) | |
parent | 24433cf8d1241991b5a264ef81dc26868b50b90e (diff) | |
download | gnunet-7a1ec37c139263e4ccb056ebf9ab4582923961d2.tar.gz gnunet-7a1ec37c139263e4ccb056ebf9ab4582923961d2.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/configuration.c | 64 | ||||
-rw-r--r-- | src/util/gnunet-base32.c | 14 |
2 files changed, 56 insertions, 22 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index 3294d11f4..d0090ae53 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006, 2007, 2008, 2009, 2013, 2020 GNUnet e.V. | 3 | Copyright (C) 2006, 2007, 2008, 2009, 2013, 2020, 2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -260,13 +260,14 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
260 | pos = memchr (&mem[r_bytes], '\n', to_read); | 260 | pos = memchr (&mem[r_bytes], '\n', to_read); |
261 | if (NULL == pos) | 261 | if (NULL == pos) |
262 | { | 262 | { |
263 | line_orig = GNUNET_strndup (&mem[r_bytes], line_size = to_read); | 263 | line_orig = GNUNET_strndup (&mem[r_bytes], |
264 | line_size = to_read); | ||
264 | r_bytes += line_size; | 265 | r_bytes += line_size; |
265 | } | 266 | } |
266 | else | 267 | else |
267 | { | 268 | { |
268 | line_orig = | 269 | line_orig = GNUNET_strndup (&mem[r_bytes], |
269 | GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes])); | 270 | line_size = (pos - &mem[r_bytes])); |
270 | r_bytes += line_size + 1; | 271 | r_bytes += line_size + 1; |
271 | } | 272 | } |
272 | line = line_orig; | 273 | line = line_orig; |
@@ -288,7 +289,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
288 | continue; | 289 | continue; |
289 | 290 | ||
290 | /* remove tailing whitespace */ | 291 | /* remove tailing whitespace */ |
291 | for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i])); | 292 | for (i = line_size - 1; |
293 | (i >= 1) && (isspace ((unsigned char) line[i])); | ||
292 | i--) | 294 | i--) |
293 | line[i] = '\0'; | 295 | line[i] = '\0'; |
294 | 296 | ||
@@ -297,26 +299,46 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
297 | ; | 299 | ; |
298 | 300 | ||
299 | /* ignore comments */ | 301 | /* ignore comments */ |
300 | if (('#' == line[0]) || ('%' == line[0])) | 302 | if ( ('#' == line[0]) || |
303 | ('%' == line[0]) ) | ||
301 | continue; | 304 | continue; |
302 | 305 | ||
303 | /* handle special "@INLINE@" directive */ | 306 | /* handle special "@INLINE@" directive */ |
304 | if (0 == strncasecmp (line, "@INLINE@ ", strlen ("@INLINE@ "))) | 307 | if (0 == strncasecmp (line, |
308 | "@INLINE@ ", | ||
309 | strlen ("@INLINE@ "))) | ||
305 | { | 310 | { |
306 | /* @INLINE@ value */ | 311 | /* @INLINE@ value */ |
307 | value = &line[strlen ("@INLINE@ ")]; | 312 | value = &line[strlen ("@INLINE@ ")]; |
308 | if (NULL != basedir) | 313 | if (NULL != basedir) |
309 | { | 314 | { |
310 | char *fn; | 315 | if ('/' == *value) |
311 | 316 | { | |
312 | GNUNET_asprintf (&fn, "%s/%s", basedir, value); | 317 | if (GNUNET_OK != |
313 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, fn)) | 318 | GNUNET_CONFIGURATION_parse (cfg, |
319 | value)) | ||
320 | { | ||
321 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
322 | break; | ||
323 | } | ||
324 | } | ||
325 | else | ||
314 | { | 326 | { |
327 | char *fn; | ||
328 | |||
329 | GNUNET_asprintf (&fn, "%s/%s", | ||
330 | basedir, | ||
331 | value); | ||
332 | if (GNUNET_OK != | ||
333 | GNUNET_CONFIGURATION_parse (cfg, | ||
334 | fn)) | ||
335 | { | ||
336 | GNUNET_free (fn); | ||
337 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
338 | break; | ||
339 | } | ||
315 | GNUNET_free (fn); | 340 | GNUNET_free (fn); |
316 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
317 | break; | ||
318 | } | 341 | } |
319 | GNUNET_free (fn); | ||
320 | } | 342 | } |
321 | else | 343 | else |
322 | { | 344 | { |
@@ -374,7 +396,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
374 | } | 396 | } |
375 | GNUNET_free (line_orig); | 397 | GNUNET_free (line_orig); |
376 | GNUNET_free (section); | 398 | GNUNET_free (section); |
377 | GNUNET_assert ((GNUNET_OK != ret) || (r_bytes == size)); | 399 | GNUNET_assert ( (GNUNET_OK != ret) || |
400 | (r_bytes == size) ); | ||
378 | return ret; | 401 | return ret; |
379 | } | 402 | } |
380 | 403 | ||
@@ -426,7 +449,16 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
426 | endsep = strrchr (fn, (int) '/'); | 449 | endsep = strrchr (fn, (int) '/'); |
427 | if (NULL != endsep) | 450 | if (NULL != endsep) |
428 | *endsep = '\0'; | 451 | *endsep = '\0'; |
429 | ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, fn); | 452 | ret = GNUNET_CONFIGURATION_deserialize (cfg, |
453 | mem, | ||
454 | fs, | ||
455 | fn); | ||
456 | if (GNUNET_OK != ret) | ||
457 | { | ||
458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
459 | _ ("Failed to parse configuration file `%s'\n"), | ||
460 | fn); | ||
461 | } | ||
430 | GNUNET_free (fn); | 462 | GNUNET_free (fn); |
431 | GNUNET_free (mem); | 463 | GNUNET_free (mem); |
432 | /* restore dirty flag - anything we set in the meantime | 464 | /* restore dirty flag - anything we set in the meantime |
diff --git a/src/util/gnunet-base32.c b/src/util/gnunet-base32.c index 2c797f56e..217185ed0 100644 --- a/src/util/gnunet-base32.c +++ b/src/util/gnunet-base32.c | |||
@@ -42,7 +42,8 @@ main (int argc, | |||
42 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | 42 | const struct GNUNET_GETOPT_CommandLineOption options[] = { |
43 | GNUNET_GETOPT_option_flag ('d', | 43 | GNUNET_GETOPT_option_flag ('d', |
44 | "decode", | 44 | "decode", |
45 | gettext_noop ("run decoder modus, otherwise runs as encoder"), | 45 | gettext_noop ( |
46 | "run decoder modus, otherwise runs as encoder"), | ||
46 | &decode), | 47 | &decode), |
47 | GNUNET_GETOPT_option_help ("Crockford base32 encoder/decoder"), | 48 | GNUNET_GETOPT_option_help ("Crockford base32 encoder/decoder"), |
48 | GNUNET_GETOPT_option_version (PACKAGE_VERSION), | 49 | GNUNET_GETOPT_option_version (PACKAGE_VERSION), |
@@ -105,11 +106,12 @@ main (int argc, | |||
105 | out_size and out_size-1 below */ | 106 | out_size and out_size-1 below */ |
106 | out_size = in_size * 5 / 8; | 107 | out_size = in_size * 5 / 8; |
107 | out = GNUNET_malloc (out_size); | 108 | out = GNUNET_malloc (out_size); |
108 | if (GNUNET_OK != | 109 | if ( (GNUNET_OK != |
109 | GNUNET_STRINGS_string_to_data (in, | 110 | GNUNET_STRINGS_string_to_data (in, |
110 | in_size, | 111 | in_size, |
111 | out, | 112 | out, |
112 | out_size)) | 113 | out_size)) && |
114 | (out_size > 0) ) | ||
113 | { | 115 | { |
114 | out_size--; | 116 | out_size--; |
115 | if (GNUNET_OK != | 117 | if (GNUNET_OK != |