Fix open file leak in /LASTLOG, in situations like:
/LASTLOG -FILE /tmp/a -FILE /tmp/a /LASTLOG -FILE /tmp/a -CLEAR /LASTLOG -FILE /tmp/a -LITERAL /LASTLOG -FILE /tmp/a -BOGUS Found by Coverity. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@243 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2c01]
|
[Changes 1.2c01]
|
||||||
|
|
||||||
|
* Fix open file leak in /LASTLOG found by Coverity. (caf)
|
||||||
|
|
||||||
* Fix file descriptor leak on SOCKS4 connection failure found by
|
* Fix file descriptor leak on SOCKS4 connection failure found by
|
||||||
Coverity. (caf)
|
Coverity. (caf)
|
||||||
|
|
||||||
|
|||||||
@@ -282,8 +282,8 @@ BUILT_IN_COMMAND(lastlog)
|
|||||||
Lastlog *start_pos;
|
Lastlog *start_pos;
|
||||||
char *match = NULL,
|
char *match = NULL,
|
||||||
*arg;
|
*arg;
|
||||||
char *file_open[] = { "wt", "at" };
|
const char *file_open_type = "w";
|
||||||
int file_open_type = 0;
|
const char *filename = NULL;
|
||||||
char *blah = NULL;
|
char *blah = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ BUILT_IN_COMMAND(lastlog)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!my_strnicmp(arg, "APPEND", len))
|
else if (!my_strnicmp(arg, "APPEND", len))
|
||||||
file_open_type = 1;
|
file_open_type = "a";
|
||||||
else if (!my_strnicmp(arg, "FILE", len))
|
else if (!my_strnicmp(arg, "FILE", len))
|
||||||
{
|
{
|
||||||
#ifdef PUBLIC_ACCESS
|
#ifdef PUBLIC_ACCESS
|
||||||
@@ -352,13 +352,11 @@ BUILT_IN_COMMAND(lastlog)
|
|||||||
#else
|
#else
|
||||||
if (args && *args)
|
if (args && *args)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename_arg = next_arg(args, &args);
|
||||||
filename = next_arg(args, &args);
|
if (filename)
|
||||||
if (!(fp = fopen(filename, file_open[file_open_type])))
|
say("Additional -FILE argument ignored");
|
||||||
{
|
else
|
||||||
bitchsay("cannot open file %s", filename);
|
filename = filename_arg;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -436,6 +434,13 @@ BUILT_IN_COMMAND(lastlog)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(fp = fopen(filename, file_open_type)))
|
||||||
|
{
|
||||||
|
bitchsay("cannot open file %s", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
start_pos = current_window->lastlog_head;
|
start_pos = current_window->lastlog_head;
|
||||||
level = current_window->lastlog_level;
|
level = current_window->lastlog_level;
|
||||||
msg_level = set_lastlog_msg_level(0);
|
msg_level = set_lastlog_msg_level(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user