Commits (3)
  • Rob Swindell's avatar
    Restore ability for MsgBase.open() to open an arbitrary SMB msgbase · 1e62752a
    Rob Swindell authored
    Before commit 5da26eca, you could pass Msgbase() the path to an SMB
    on the disk and open() it, no configuration needed. As of 2 years
    ago, I broke that, and passing a path to an SMB would open the "mail" base
    instead - most unexpected. This is a feature of smb_open_sub() which we
    switched to using (from smb_open()), so go back to using smb_open() when
    an unrecognized code is pass to the constructor.
    
    This has the negative consequence that the "mail" base can't be created
    via JS. Probably should fix that.
    1e62752a
  • Rob Swindell's avatar
    Use smb_open_sub() for the "mail" base too · dc4b1bd9
    Rob Swindell authored
    This restores the ability for JS MsgBase() to be used to create the
    initial mail message base properly, if needed.
    
    This means that the 'subnum' should now be equal to scfg.total_subs
    when referencing an arbitrary SMB via path (not in the configuration).
    dc4b1bd9
  • Rob Swindell's avatar
    Fix segfault when printing Bad-echo name after failing to load cfg · 2962e4a5
    Rob Swindell authored
    This is a weird one: sbbsecho ran right as I was saving msgs.cnf via
    SCFG and it seems like it loaded 0-byte msgs.cnf into memory and this
    segfault was a result of trying to print sub[INVALID_SUB]->code.
    
    The use of [f]nopen() with proper share perms should have prevented this
    (truncated msgs.cnf read) from happening, so there's something else afoot here.
    2962e4a5
...@@ -85,7 +85,7 @@ js_open(JSContext *cx, uintN argc, jsval *arglist) ...@@ -85,7 +85,7 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE); JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if(p->smb.subnum==INVALID_SUB if(p->smb.subnum >= scfg->total_subs
&& strchr(p->smb.file,'/')==NULL && strchr(p->smb.file,'/')==NULL
&& strchr(p->smb.file,'\\')==NULL) { && strchr(p->smb.file,'\\')==NULL) {
JS_ReportError(cx,"Unrecognized msgbase code: %s",p->smb.file); JS_ReportError(cx,"Unrecognized msgbase code: %s",p->smb.file);
...@@ -93,7 +93,11 @@ js_open(JSContext *cx, uintN argc, jsval *arglist) ...@@ -93,7 +93,11 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
if((p->smb_result = smb_open_sub(scfg, &(p->smb), p->smb.subnum)) != SMB_SUCCESS) { if(p->smb.subnum >= scfg->total_subs && p->smb.subnum != INVALID_SUB)
p->smb_result = smb_open(&(p->smb));
else
p->smb_result = smb_open_sub(scfg, &(p->smb), p->smb.subnum);
if(p->smb_result != SMB_SUCCESS) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
return JS_TRUE; return JS_TRUE;
} }
...@@ -3418,7 +3422,6 @@ js_msgbase_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3418,7 +3422,6 @@ js_msgbase_constructor(JSContext *cx, uintN argc, jsval *arglist)
,scfg->sub[p->smb.subnum]->data_dir,scfg->sub[p->smb.subnum]->code); ,scfg->sub[p->smb.subnum]->data_dir,scfg->sub[p->smb.subnum]->code);
} else { /* unknown code */ } else { /* unknown code */
SAFECOPY(p->smb.file,base); SAFECOPY(p->smb.file,base);
p->smb.subnum=INVALID_SUB;
} }
} }
......
...@@ -6467,7 +6467,8 @@ int main(int argc, char **argv) ...@@ -6467,7 +6467,8 @@ int main(int argc, char **argv)
} }
if(cfg.badecho >= 0) if(cfg.badecho >= 0)
lprintf(LOG_DEBUG, "Bad-echo area: %s", scfg.sub[cfg.area[cfg.badecho].sub]->code); lprintf(LOG_DEBUG, "Bad-echo area: %s"
,cfg.area[cfg.badecho].sub == INVALID_SUB ? "INVALID_SUB" : scfg.sub[cfg.area[cfg.badecho].sub]->code);
if(cfg.auto_add_subs) { if(cfg.auto_add_subs) {
for(unsigned subnum = 0; subnum < scfg.total_subs; subnum++) { for(unsigned subnum = 0; subnum < scfg.total_subs; subnum++) {
......