diff --git a/src/log.c b/src/log.c index 33fdd2b9..d5f89721 100644 --- a/src/log.c +++ b/src/log.c @@ -74,12 +74,19 @@ FILE *log_open_default(const char*default_filename, const int mode) if (path == NULL) path = getenv("HOMEPATH"); if(path == NULL) - return NULL; + { + log_handle=fopen(default_filename,(mode==TD_LOG_CREATE?"w":"a")); + return log_handle; + } /* Check to avoid buffer overflow may not be 100% bullet proof */ - if(strlen(path)+strlen(default_filename)+2 > 2048) - return NULL; - filename=(char*)MALLOC(2048); + if(strlen(path)+strlen(default_filename)+2 > 4096) + { + log_handle=fopen(default_filename,(mode==TD_LOG_CREATE?"w":"a")); + return log_handle; + } + filename=(char*)MALLOC(4096); #ifdef __CYGWIN__ +/* FIXME */ cygwin_conv_to_posix_path(path, filename); #else strcpy(filename, path); @@ -97,7 +104,10 @@ FILE *log_open_default(const char*default_filename, const int mode) char *path; path = getenv("HOME"); if(path == NULL) - return NULL; + { + log_handle=fopen(default_filename,(mode==TD_LOG_CREATE?"w":"a")); + return log_handle; + } filename=(char*)MALLOC(strlen(path)+strlen(default_filename)+2); strcpy(filename, path); strcat(filename, "/");