--- libaitsess/src/aitsess.c 2012/02/10 16:54:37 1.3.2.4 +++ libaitsess/src/aitsess.c 2012/02/10 17:14:21 1.3.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsess.c,v 1.3.2.4 2012/02/10 16:54:37 misho Exp $ +* $Id: aitsess.c,v 1.3.2.5 2012/02/10 17:14:21 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -116,8 +116,9 @@ sess_initSession(int id, const char *csFName, ait_sess } } memset(*Sess, 0, sizeof(ait_sess_t)); + strlcpy((*Sess)->name, csFName, sizeof (*Sess)->name); - h = open(csFName, O_WRONLY | O_CREAT | O_EXCL, MEM_MODE); + h = open((*Sess)->name, O_WRONLY | O_CREAT | O_EXCL, MEM_MODE); if (h == -1) { if (errno != EEXIST) { LOGERR; @@ -125,7 +126,7 @@ sess_initSession(int id, const char *csFName, ait_sess return -1; } /* If key file exist, session already connected */ - h = open(csFName, O_RDONLY); + h = open((*Sess)->name, O_RDONLY); if (h == -1) { LOGERR; free(*Sess); @@ -228,8 +229,8 @@ sess_freeSession(const char *csFName, ait_sess_t ** __ memset(&(*Sess)->sess, 0, sizeof (*Sess)->sess); (*Sess)->type = SHARED_UNKNOWN; - if (csFName) - unlink(csFName); + if (csFName && (*Sess)->name) + unlink((*Sess)->name); if (*Sess) free(*Sess); *Sess = NULL;