Commits (10)
......@@ -1378,6 +1378,14 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
offset=smb_allocdat(&smb,length,1);
smb_close_da(&smb);
if(offset < 0) {
smb_unlocksmbhdr(&smb);
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
errormsg(WHERE,ERR_ALLOC,msgpath,length);
return(false);
}
if((instream=fnopen(&file,msgpath,O_RDONLY|O_BINARY))==NULL) {
smb_freemsgdat(&smb,offset,length,1);
smb_unlocksmbhdr(&smb);
......
......@@ -156,6 +156,12 @@ int pktdump(FILE* fp, const char* fname, FILE* good, FILE* bad)
while(!feof(fp)) {
offset=ftell(fp);
if(offset < 0) {
printf("%s ERROR %d getting offset!\n"
,fname
,errno);
break;
}
if(fread(&pkdmsg.type, 1, sizeof(pkdmsg.type), fp) != sizeof(pkdmsg.type))
break;
......@@ -368,7 +374,8 @@ int main(int argc, char** argv)
if(length <= sizeof(fpkthdr_t) + sizeof(uint16_t) // no messages
|| length == ftell(fp)) {
puts("All good.");
remove(good_fname);
if(remove(good_fname) != 0)
fprintf(stderr, "!ERROR %d removing %s\n", errno, good_fname);
}
}
if(bad != NULL) {
......@@ -378,7 +385,8 @@ int main(int argc, char** argv)
if(length <= sizeof(fpkthdr_t) + sizeof(uint16_t) // no messages
|| length == ftell(fp)) {
puts("All bad.");
remove(bad_fname);
if(remove(bad_fname) != 0)
fprintf(stderr, "!ERROR %d removing %s\n", errno, bad_fname);
}
}
fclose(fp);
......
......@@ -406,11 +406,11 @@ public:
char client_ipaddr[INET6_ADDRSTRLEN];
char local_addr[INET6_ADDRSTRLEN];
#ifdef USE_CRYPTLIB
CRYPT_SESSION ssh_session;
CRYPT_SESSION ssh_session=-1;
#endif
int session_channel;
int session_channel=-1;
bool ssh_mode;
SOCKET passthru_socket;
SOCKET passthru_socket=INVALID_SOCKET;
bool passthru_socket_active;
void passthru_socket_activate(bool);
bool passthru_thread_running;
......@@ -433,7 +433,7 @@ public:
RingBuf inbuf;
RingBuf outbuf;
bool WaitForOutbufEmpty(int timeout) { return WaitForEvent(outbuf.empty_event, timeout) == WAIT_OBJECT_0; }
HANDLE input_thread;
HANDLE input_thread=nullptr;
pthread_mutex_t input_thread_mutex;
bool input_thread_mutex_created;
pthread_mutex_t ssh_mutex;
......@@ -475,14 +475,14 @@ public:
bool event_thread_running;
bool output_thread_running;
bool input_thread_running;
bool terminate_output_thread;
bool terminate_output_thread=false;
JSRuntime* js_runtime;
JSContext* js_cx;
JSObject* js_glob;
JSObject* js_glob=nullptr;
JSRuntime* js_hotkey_runtime;
JSContext* js_hotkey_cx;
JSObject* js_hotkey_glob;
JSObject* js_hotkey_glob=nullptr;
js_callback_t js_callback{};
long js_execfile(const char *fname, const char* startup_dir, JSObject* scope = NULL, JSContext* cx = NULL, JSObject* glob = NULL);
long js_execxtrn(const char *fname, const char* startup_dir);
......
......@@ -113,7 +113,7 @@ while(l>-1L) {
if(pause && lncntr>=20) {
printf("More (Y/n) ? ");
fflush(stdout);
char ch = getchar();
int ch = getchar();
if(ch == CTRL_C || toupper(ch) == 'N')
break;
printf("\r");
......
......@@ -132,24 +132,26 @@ void sbbs_t::sif(char *fname, char *answers, long len)
int file;
long length,l=0,m,top,a=0;
*answers = 0;
sprintf(str,"%s%s.sif",cfg.text_dir,fname);
if((file=nopen(str,O_RDONLY))==-1) {
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
answers[0]=0;
return;
}
length=(long)filelength(file);
if(length < 0) {
errormsg(WHERE, ERR_CHK, str, length);
return;
}
if((buf=(char *)calloc(length + 1, 1))==0) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,length);
answers[0]=0;
return;
}
if(lread(file,buf,length)!=length) {
close(file);
free(buf);
errormsg(WHERE,ERR_READ,str,length);
answers[0]=0;
return;
}
close(file);
......
......@@ -1861,11 +1861,12 @@ void decompile(FILE *bin, FILE *srcfile)
break;
case CS_COMPARE_ARS:
fread(&uch,1,1,bin);
p=(char *)malloc(uch);
fread(p,uch,1,bin);
WRITE_NAME("COMPARE_ARS");
sprintf(strchr(src,0),"%s\n",decompile_ars((uchar*)p,uch));
free(p);
if((p=(char *)malloc(uch)) != NULL) {
fread(p,uch,1,bin);
WRITE_NAME("COMPARE_ARS");
sprintf(strchr(src,0),"%s\n",decompile_ars((uchar*)p,uch));
free(p);
}
break;
case CS_TOGGLE_USER_MISC:
MLNG("TOGGLE_USER_MISC");
......
......@@ -1681,6 +1681,12 @@ bool sbbs_t::editmsg(smb_t* smb, smbmsg_t *msg)
smb_close_da(smb);
}
if(offset < 0) {
smb_unlocksmbhdr(smb);
errormsg(WHERE,ERR_ALLOC,msgtmp,length);
return false;
}
msg->hdr.offset=(uint32_t)offset;
if((file=open(msgtmp,O_RDONLY|O_BINARY))==-1
|| (instream=fdopen(file,"rb"))==NULL) {
......
......@@ -129,6 +129,9 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
off_t sda_offset;
off_t flen;
if(offset < 0)
return SMB_ERR_DAT_OFFSET;
if(smb->status.attr&SMB_HYPERALLOC) /* do nothing */
return(SMB_SUCCESS);
......