[NetworkManager-openvpn/bg/read-line-loop] utils: fix infinite loop when reading from binary file



commit 62ce54accfbbfb3a5e35232a0baa2ca0ae892c6d
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Thu Sep 20 18:57:39 2018 +0200

    utils: fix infinite loop when reading from binary file
    
    If the file is binary, g_io_channel_read_line() returns
    G_IO_STATUS_ERROR with error "Invalid byte sequence in conversion
    input" and we loop forever. Invert the loop condition.
    
    Reported-by: Matteo Croce <mcroce redhat com>

 shared/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/shared/utils.c b/shared/utils.c
index 58d9089..47dd26a 100644
--- a/shared/utils.c
+++ b/shared/utils.c
@@ -79,7 +79,7 @@ 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) {
+       while (g_io_channel_read_line (pem_chan, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
                if (str) {
                        if (g_str_has_prefix (str, PROC_TYPE_TAG) || g_str_has_prefix (str, PKCS8_TAG)) {
                                encrypted = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]