Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 07ea6de5 authored by rswindell's avatar rswindell

Added input_thread_mutex_locked variable to sbbs_t to prevent someonel/thing

from unlocking the mutex (Win32 critical section) when it hasn't been locked
(outside of input_thread).
parent 5407bf6e
......@@ -998,10 +998,13 @@ js_lock_input(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
if(argc)
JS_ValueToBoolean(cx, argv[0], &lock);
if(lock)
if(lock) {
pthread_mutex_lock(&sbbs->input_thread_mutex);
else
sbbs->input_thread_mutex_locked=true;
} else if(sbbs->input_thread_mutex_locked) {
pthread_mutex_unlock(&sbbs->input_thread_mutex);
sbbs->input_thread_mutex_locked=false;
}
*rval=JSVAL_VOID;
return(JS_TRUE);
......
......@@ -1858,6 +1858,7 @@ sbbs_t::sbbs_t(ushort node_num, DWORD addr, char* name, SOCKET sd,
event_thread_running = false;
input_thread_running = false;
output_thread_running = false;
input_thread_mutex_locked = false;
if(client_info==NULL)
memset(&client,0,sizeof(client));
......
......@@ -161,6 +161,7 @@ public:
sem_t output_sem;
HANDLE input_thread;
pthread_mutex_t input_thread_mutex;
bool input_thread_mutex_locked; // by someone other than the input_thread
int outcom(uchar ch); // send character
int incom(void); // receive character
......
......@@ -555,8 +555,10 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
fclose(fp);
/* not temporary */
if(!(mode&EX_INR))
if(!(mode&EX_INR)) {
pthread_mutex_lock(&input_thread_mutex);
input_thread_mutex_locked=true;
}
}
if(!CreateProcess(
......@@ -572,7 +574,10 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
&process_info // pointer to PROCESS_INFORMATION
)) {
XTRN_CLEANUP;
pthread_mutex_unlock(&input_thread_mutex);
if(input_thread_mutex_locked) {
pthread_mutex_unlock(&input_thread_mutex);
input_thread_mutex_locked=false;
}
SetLastError(last_error); /* Restore LastError */
errormsg(WHERE, ERR_EXEC, realcmdline, mode);
return(GetLastError());
......@@ -920,7 +925,10 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
if(native) {
ulong l=0;
ioctlsocket(client_socket, FIONBIO, &l);
pthread_mutex_unlock(&input_thread_mutex);
if(input_thread_mutex_locked) {
pthread_mutex_unlock(&input_thread_mutex);
input_thread_mutex_locked=false;
}
}
curatr=~0; // Can't guarantee current attributes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment