diff options
| author | Martin Willi <martin@revosec.ch> | 2012-07-13 15:42:14 +0200 |
|---|---|---|
| committer | Martin Willi <martin@revosec.ch> | 2012-07-13 15:43:04 +0200 |
| commit | d19f0ae3e0a6bbff549911e910c06d8ef51ad563 (patch) | |
| tree | 63d2f3ee37b5b436541effe3f066f4f1a5393512 /src/libcharon/plugins/android | |
| parent | e0bfc4d63ceabeaef3f1d51191196198c8265e65 (diff) | |
| download | strongswan-d19f0ae3e0a6bbff549911e910c06d8ef51ad563.tar.bz2 strongswan-d19f0ae3e0a6bbff549911e910c06d8ef51ad563.tar.xz | |
Don't modify the message string passed to logger, as it gets reused
Diffstat (limited to 'src/libcharon/plugins/android')
| -rw-r--r-- | src/libcharon/plugins/android/android_logger.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libcharon/plugins/android/android_logger.c b/src/libcharon/plugins/android/android_logger.c index 1f6042c56..0c5f609f7 100644 --- a/src/libcharon/plugins/android/android_logger.c +++ b/src/libcharon/plugins/android/android_logger.c @@ -45,26 +45,27 @@ struct private_android_logger_t { mutex_t *mutex; }; - METHOD(logger_t, log_, void, private_android_logger_t *this, debug_t group, level_t level, - int thread, ike_sa_t* ike_sa, char *message) + int thread, ike_sa_t* ike_sa, const char *message) { int prio = level > 1 ? ANDROID_LOG_DEBUG : ANDROID_LOG_INFO; char sgroup[16]; - char *current = message, *next; + const char *current = message, *next; snprintf(sgroup, sizeof(sgroup), "%N", debug_names, group); this->mutex->lock(this->mutex); - while (current) + while (TRUE) { /* log each line separately */ next = strchr(current, '\n'); - if (next) + if (next == NULL) { - *(next++) = '\0'; + __android_log_print(prio, "charon", "%.2d[%s] %s\n", + thread, sgroup, current); + break; } - __android_log_print(prio, "charon", "%.2d[%s] %s\n", - thread, sgroup, current); - current = next; + __android_log_print(prio, "charon", "%.2d[%s] %.*s\n", + thread, sgroup, (int)(next - current), current); + current = next + 1; } this->mutex->unlock(this->mutex); } |
