Mercurial > hg > freeDiameter
changeset 937:6e7437162f26
Do not change the default file name if extension is not found during configuration parsing, so that dl_open can use LD_LIBRARY_PATH successfully
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 10 Mar 2013 04:24:36 +0100 |
parents | 8ee9f8183ab8 |
children | 4158151cc694 bbc08d58325a |
files | libfdcore/fdd.y |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/fdd.y Sat Mar 09 15:56:34 2013 +0100 +++ b/libfdcore/fdd.y Sun Mar 10 04:24:36 2013 +0100 @@ -322,15 +322,18 @@ CHECK_MALLOC_DO( fname = malloc( strlen(bkp) + strlen(DEFAULT_EXTENSIONS_PATH) + 2 ), { yyerror (&yylloc, conf, "Not enough memory"); YYERROR; } ); sprintf(fname, DEFAULT_EXTENSIONS_PATH "/%s", bkp); - free(bkp); fd = fopen(fname, "r"); + if (fd == NULL) { + free(fname); + fname = bkp; + } else { + free(bkp); + } } - if (fd == NULL) { - int ret = errno; - TRACE_DEBUG_ERROR("WARNING: Unable to open extension file %s for reading: %s\nLD_LIBRARY_PATH will be used.\n", fname, strerror(ret)); - } else { + if (fd != NULL) { fclose(fd); - } + } /* otherwise, LD_LIBRARY_PATH will be tested by dl_open. + This should not give any security issue, otherwise we can add an "else fail" here. */ /* Try and open the configuration file (optional) */ cfname = $4;