Skip to content
Snippets Groups Projects
Commit 67c3a42e authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Insure that message base is closed before opening another.

This should address the issue raised by Michael J. Ryan in issue #4.
The command in question ("GROUP") would attempt to open the message
base associated with the specified newsgroup name without closing
the currently open/selected message base (if there was one). This would
result in multiple simultaneously open message bases and could result
in an exhaustion of open file descriptors leading to a failure to open
any additional files (includign message bases) and thus a subsequent
"GROUP" command would fail with the wrong "!no such group" error.
parent 68d9921d
No related branches found
No related tags found
No related merge requests found
...@@ -317,6 +317,8 @@ while(client.socket.is_connected && !quit) { ...@@ -317,6 +317,8 @@ while(client.socket.is_connected && !quit) {
pattern=cmd[2]; pattern=cmd[2];
writeln("215 list of newsgroups follows"); writeln("215 list of newsgroups follows");
if(include_mail && user.security.level == 99 && wildmatch("mail", pattern)) { if(include_mail && user.security.level == 99 && wildmatch("mail", pattern)) {
if(msgbase && msgbase.is_open)
msgbase.close();
msgbase=new MsgBase("mail"); msgbase=new MsgBase("mail");
if(msgbase.open()==true) { if(msgbase.open()==true) {
writeln(format("mail %u %u n", msgbase.last_msg, msgbase.first_msg)); writeln(format("mail %u %u n", msgbase.last_msg, msgbase.first_msg));
...@@ -327,6 +329,8 @@ while(client.socket.is_connected && !quit) { ...@@ -327,6 +329,8 @@ while(client.socket.is_connected && !quit) {
for(s in msg_area.grp_list[g].sub_list) { for(s in msg_area.grp_list[g].sub_list) {
if(!wildmatch(msg_area.grp_list[g].sub_list[s].newsgroup, pattern)) if(!wildmatch(msg_area.grp_list[g].sub_list[s].newsgroup, pattern))
continue; continue;
if(msgbase && msgbase.is_open)
msgbase.close();
msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code); msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code);
if(msgbase.open!=undefined && msgbase.open()==false) if(msgbase.open!=undefined && msgbase.open()==false)
continue; continue;
...@@ -443,6 +447,8 @@ while(client.socket.is_connected && !quit) { ...@@ -443,6 +447,8 @@ while(client.socket.is_connected && !quit) {
writeln("231 list of new newsgroups since " + compare.toISOString() + " follows"); writeln("231 list of new newsgroups since " + compare.toISOString() + " follows");
for(g in msg_area.grp_list) { for(g in msg_area.grp_list) {
for(s in msg_area.grp_list[g].sub_list) { for(s in msg_area.grp_list[g].sub_list) {
if(msgbase && msgbase.is_open)
msgbase.close();
msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code); msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code);
var ini_file = new File(msgbase.file + ".ini"); var ini_file = new File(msgbase.file + ".ini");
if(ini_file.open("r")) { if(ini_file.open("r")) {
...@@ -481,6 +487,8 @@ while(client.socket.is_connected && !quit) { ...@@ -481,6 +487,8 @@ while(client.socket.is_connected && !quit) {
found=true; found=true;
} }
else if(include_mail && user.security.level==99 && cmd[1].toLowerCase()=="mail") { else if(include_mail && user.security.level==99 && cmd[1].toLowerCase()=="mail") {
if(msgbase && msgbase.is_open)
msgbase.close();
msgbase=new MsgBase("mail"); msgbase=new MsgBase("mail");
if(msgbase.open()==true) { if(msgbase.open()==true) {
selected = { newsgroup: "mail" }; selected = { newsgroup: "mail" };
...@@ -488,6 +496,8 @@ while(client.socket.is_connected && !quit) { ...@@ -488,6 +496,8 @@ while(client.socket.is_connected && !quit) {
} }
} }
if(!found) { if(!found) {
if(msgbase && msgbase.is_open)
msgbase.close();
for(g in msg_area.grp_list) for(g in msg_area.grp_list)
for(s in msg_area.grp_list[g].sub_list) for(s in msg_area.grp_list[g].sub_list)
if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()==cmd[1].toLowerCase()) { if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()==cmd[1].toLowerCase()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment