diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-03-27 15:04:33 +0000 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-03-27 15:04:33 +0000 |
| commit | d4e218dfebe021d37acdd7af4a58e219a39ead90 (patch) | |
| tree | 3934027198f9a6c8e687fb5237313a89bbd8f675 | |
| parent | b09ef2e015287adfc16c9f71f0f7c5b3aba3502c (diff) | |
| download | lasso-d4e218dfebe021d37acdd7af4a58e219a39ead90.tar.gz lasso-d4e218dfebe021d37acdd7af4a58e219a39ead90.tar.xz lasso-d4e218dfebe021d37acdd7af4a58e219a39ead90.zip | |
Core: handle g_io_channel creation failure
* lasso/xml/tools.c:
in lasso_load_certs_from_pem_certs_chain_file if
g_io_channel_new_file fails return NULL and print a warning.
If path is NULL or 0-length also returns NULL.
| -rw-r--r-- | lasso/xml/tools.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index 3e40d8b4..ab38cdb5 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -298,7 +298,15 @@ lasso_load_certs_from_pem_certs_chain_file(const char* pem_certs_chain_file) GString *cert = NULL; gint ret; - g_return_val_if_fail(pem_certs_chain_file != NULL, NULL); + /* No file just return NULL */ + if (! pem_certs_chain_file || strlen(pem_certs_chain_file) == 0) { + return NULL; + } + gioc = g_io_channel_new_file(pem_certs_chain_file, "r", NULL); + if (! gioc) { + message(G_LOG_LEVEL_WARNING, "Cannot open chain file %s", pem_certs_chain_file); + return NULL; + } /* create keys manager */ keys_mngr = xmlSecKeysMngrCreate(); @@ -315,7 +323,6 @@ lasso_load_certs_from_pem_certs_chain_file(const char* pem_certs_chain_file) return NULL; } - gioc = g_io_channel_new_file(pem_certs_chain_file, "r", NULL); while (g_io_channel_read_line(gioc, &line, &len, &pos, NULL) == G_IO_STATUS_NORMAL) { if (g_strstr_len(line, 64, "BEGIN CERTIFICATE") != NULL) { cert = g_string_new(line); |
