diff options
-rw-r--r-- | src/util/common_logging.c | 51 | ||||
-rw-r--r-- | src/util/crypto_random.c | 31 |
2 files changed, 59 insertions, 23 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index f875d165d..be2e084b5 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -817,32 +817,39 @@ output_message (enum GNUNET_ErrorType kind, | |||
817 | if ( (NULL != GNUNET_stderr) && | 817 | if ( (NULL != GNUNET_stderr) && |
818 | (NULL == loggers) ) | 818 | (NULL == loggers) ) |
819 | { | 819 | { |
820 | if (kind == GNUNET_ERROR_TYPE_MESSAGE) { | 820 | if (kind == GNUNET_ERROR_TYPE_MESSAGE) |
821 | /* The idea here is to produce "normal" output messages | 821 | { |
822 | * for end users while still having the power of the | 822 | /* The idea here is to produce "normal" output messages |
823 | * logging engine for developer needs. So ideally this | 823 | * for end users while still having the power of the |
824 | * is what it should look like when CLI tools are used | 824 | * logging engine for developer needs. So ideally this |
825 | * interactively, yet the same message shouldn't look | 825 | * is what it should look like when CLI tools are used |
826 | * this way if the output is going to logfiles or robots | 826 | * interactively, yet the same message shouldn't look |
827 | * instead. Is this the right place to do this? --lynX | 827 | * this way if the output is going to logfiles or robots |
828 | */ | 828 | * instead. |
829 | FPRINTF (GNUNET_stderr, | 829 | */ |
830 | "* %s", | 830 | FPRINTF (GNUNET_stderr, |
831 | msg); | 831 | "* %s", |
832 | } else { | 832 | msg); |
833 | FPRINTF (GNUNET_stderr, | 833 | } |
834 | "%s %s %s %s", | 834 | else |
835 | datestr, | 835 | { |
836 | comp, | 836 | FPRINTF (GNUNET_stderr, |
837 | GNUNET_error_type_to_string (kind), | 837 | "%s %s %s %s", |
838 | msg); | 838 | datestr, |
839 | comp, | ||
840 | GNUNET_error_type_to_string (kind), | ||
841 | msg); | ||
839 | } | 842 | } |
840 | fflush (GNUNET_stderr); | 843 | fflush (GNUNET_stderr); |
841 | } | 844 | } |
842 | pos = loggers; | 845 | pos = loggers; |
843 | while (pos != NULL) | 846 | while (NULL != pos) |
844 | { | 847 | { |
845 | pos->logger (pos->logger_cls, kind, comp, datestr, msg); | 848 | pos->logger (pos->logger_cls, |
849 | kind, | ||
850 | comp, | ||
851 | datestr, | ||
852 | msg); | ||
846 | pos = pos->next; | 853 | pos = pos->next; |
847 | } | 854 | } |
848 | #if WINDOWS | 855 | #if WINDOWS |
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 2163a9731..df6d3fb9b 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -269,6 +269,28 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max) | |||
269 | 269 | ||
270 | 270 | ||
271 | /** | 271 | /** |
272 | * Allocation wrapper for libgcrypt, used to avoid bad locking | ||
273 | * strategy of libgcrypt implementation. | ||
274 | */ | ||
275 | static void * | ||
276 | w_malloc (size_t n) | ||
277 | { | ||
278 | return calloc (n, 1); | ||
279 | } | ||
280 | |||
281 | |||
282 | /** | ||
283 | * Allocation wrapper for libgcrypt, used to avoid bad locking | ||
284 | * strategy of libgcrypt implementation. | ||
285 | */ | ||
286 | static int | ||
287 | w_check (const void *p) | ||
288 | { | ||
289 | return 0; /* not secure memory */ | ||
290 | } | ||
291 | |||
292 | |||
293 | /** | ||
272 | * Initialize libgcrypt. | 294 | * Initialize libgcrypt. |
273 | */ | 295 | */ |
274 | void __attribute__ ((constructor)) | 296 | void __attribute__ ((constructor)) |
@@ -283,6 +305,13 @@ GNUNET_CRYPTO_random_init () | |||
283 | NEED_LIBGCRYPT_VERSION); | 305 | NEED_LIBGCRYPT_VERSION); |
284 | GNUNET_assert (0); | 306 | GNUNET_assert (0); |
285 | } | 307 | } |
308 | /* set custom allocators */ | ||
309 | gcry_set_allocation_handler (&w_malloc, | ||
310 | &w_malloc, | ||
311 | &w_check, | ||
312 | &realloc, | ||
313 | &free); | ||
314 | /* Disable use of secure memory */ | ||
286 | if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0))) | 315 | if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0))) |
287 | FPRINTF (stderr, | 316 | FPRINTF (stderr, |
288 | "Failed to set libgcrypt option %s: %s\n", | 317 | "Failed to set libgcrypt option %s: %s\n", |