Zero length of log file name interpreted as no log file needed

This commit is contained in:
kapyar 2003-10-26 19:26:08 +00:00
parent ed2e49c9dc
commit 07c98cc84e

View File

@ -28,7 +28,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: log.c,v 1.3 2003/10/10 20:44:06 kapyar Exp $
* $Id: log.c,v 1.4 2003/10/26 19:26:08 kapyar Exp $
*/
#include "log.h"
@ -46,13 +46,21 @@ log_init(char *logname)
int maxlen = INTBUFSIZE;
/* checking log file name */
if (*logname != '/')
if (*logname == '/')
strncpy(logfullname, logname, maxlen);
else
{
if (!*logname)
{
/* logfile isn't needed */
*logfullname = '\0';
return RC_OK;
}
/* append default log path */
strncpy(logfullname, LOGPATH, maxlen);
maxlen -= strlen(logfullname);
strncat(logfullname, logname, maxlen);
}
else strncpy(logfullname, logname, maxlen);
logfile = fopen(logfullname, "at");
if (logfile)