[network-manager-openvpn] core: don't crash checking whether keys are encrypted (rh #615875)
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] core: don't crash checking whether keys are encrypted (rh #615875)
- Date: Wed, 21 Jul 2010 22:53:38 +0000 (UTC)
commit 28c66ad4270b3092f8fa870589acee1359ba1889
Author: Dan Williams <dcbw redhat com>
Date: Tue Jul 20 15:21:25 2010 -0700
core: don't crash checking whether keys are encrypted (rh #615875)
g_io_channel_read_line() may return NULL strings, so handle that.
common/utils.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/common/utils.c b/common/utils.c
index 09cef38..1c557f7 100644
--- a/common/utils.c
+++ b/common/utils.c
@@ -73,12 +73,14 @@ is_encrypted (const char *filename)
if (!pem_chan)
return FALSE;
- while ( g_io_channel_read_line (pem_chan, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF
- && !encrypted) {
- if ( !strncmp (str, PROC_TYPE_TAG, strlen (PROC_TYPE_TAG))
- || !strncmp (str, PKCS8_TAG, strlen (PKCS8_TAG)))
- encrypted = TRUE;
- g_free (str);
+ while (g_io_channel_read_line (pem_chan, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF) {
+ if (str) {
+ if (g_str_has_prefix (str, PROC_TYPE_TAG) || g_str_has_prefix (str, PKCS8_TAG)) {
+ encrypted = TRUE;
+ break;
+ }
+ g_free (str);
+ }
}
g_io_channel_shutdown (pem_chan, FALSE, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]