mirror of
https://github.com/3cky/mbusd.git
synced 2025-01-30 22:21:33 +01:00
Zero length of log file name interpreted as no log file needed
This commit is contained in:
parent
ed2e49c9dc
commit
07c98cc84e
14
src/log.c
14
src/log.c
@ -28,7 +28,7 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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"
|
#include "log.h"
|
||||||
@ -46,13 +46,21 @@ log_init(char *logname)
|
|||||||
int maxlen = INTBUFSIZE;
|
int maxlen = INTBUFSIZE;
|
||||||
|
|
||||||
/* checking log file name */
|
/* 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);
|
strncpy(logfullname, LOGPATH, maxlen);
|
||||||
maxlen -= strlen(logfullname);
|
maxlen -= strlen(logfullname);
|
||||||
strncat(logfullname, logname, maxlen);
|
strncat(logfullname, logname, maxlen);
|
||||||
}
|
}
|
||||||
else strncpy(logfullname, logname, maxlen);
|
|
||||||
|
|
||||||
logfile = fopen(logfullname, "at");
|
logfile = fopen(logfullname, "at");
|
||||||
if (logfile)
|
if (logfile)
|
||||||
|
Loading…
Reference in New Issue
Block a user