From: Alan T. DeKok Date: Wed, 15 Apr 2009 17:49:31 +0000 (+0200) Subject: Don't leak FD's on empty values. X-Git-Tag: release_2_1_7~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e67f2acf5c6f5f33e6a66d4bf344931274394986;p=thirdparty%2Ffreeradius-server.git Don't leak FD's on empty values. Patch from Stephan Jaeger --- diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index 0dc1486bb26..eecde9e44ae 100755 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -195,21 +195,6 @@ static int do_linelog(void *instance, REQUEST *request) rlm_linelog_t *inst = (rlm_linelog_t*) instance; const char *value = inst->line; - /* - * FIXME: Check length. - */ - if (strcmp(inst->filename, "syslog") != 0) { - radius_xlat(buffer, sizeof(buffer), inst->filename, request, - NULL); - - fd = open(buffer, O_WRONLY | O_APPEND | O_CREAT, 0600); - if (fd == -1) { - radlog(L_ERR, "rlm_linelog: Failed to open %s: %s", - buffer, strerror(errno)); - return RLM_MODULE_FAIL; - } - } - if (inst->reference) { CONF_ITEM *ci; CONF_PAIR *cp; @@ -248,6 +233,21 @@ static int do_linelog(void *instance, REQUEST *request) } do_log: + /* + * FIXME: Check length. + */ + if (strcmp(inst->filename, "syslog") != 0) { + radius_xlat(buffer, sizeof(buffer), inst->filename, request, + NULL); + + fd = open(buffer, O_WRONLY | O_APPEND | O_CREAT, 0600); + if (fd == -1) { + radlog(L_ERR, "rlm_linelog: Failed to open %s: %s", + buffer, strerror(errno)); + return RLM_MODULE_FAIL; + } + } + /* * FIXME: Check length. */