Commit Graph

120 Commits

Author SHA1 Message Date
Bernhard Miklautz
81d422588e winrp/thread: don't call pthread_exit on return
As the pthread_exit man page states pthread_exit is called implicitly
when the start function returns.
2015-07-24 14:52:31 +02:00
Bernhard Miklautz
ca150f2255 winpr/thread: small cleanups
Also adds error checking of winpr_StartThread in winpr_StartThread.
2015-07-23 11:52:49 +02:00
Armin Novak
9af2e22d51 Fixed mutex unlocking and return checks. 2015-07-16 17:07:29 +02:00
Bernhard Miklautz
68e8569110 winpr/synch: remove the dependency on winsock.h
winsock.h pulls in a lot of defines and dependencies that are not
required and partially unwanted in winpr's core (for parts that are not
related to network). In order to get rid of this dependency and have an
independent defines for extended winpr functions the WINPR_FD_* defines
are used internally (and for exposed functions). Where required, like in
WSAEventSelect, the FD_* is mapped to WINPR_FD_*.
2015-07-14 11:39:41 +02:00
Armin Novak
d18b0fbeb4 Handle API updated. 2015-07-03 09:52:52 +02:00
Bernhard Miklautz
c7adb569ff CreateProcess: fix setting of default handler
If SA_SIGINFO isn't set in the flags sa_handler is used
instead of sa_sigaction.

This fixes also the compiler warning:

FreeRDP/winpr/libwinpr/thread/process.c: In function ‘_CreateProcessExA’:
FreeRDP/winpr/libwinpr/thread/process.c:282:20: warning: assignment from
       incompatible pointer type [enabled by default]
2015-07-02 12:25:48 +02:00
Bernhard Miklautz
be53e9e029 CreateProcess: two fixes
* change to lpCurrentDirectory if set even if no token was supplied
* fix wrong check - add missing !

This was part of akallabeth's PR #2714.
2015-07-02 12:05:46 +02:00
Norbert Federa
c84e90bf06 winpr: fix CreateProcess signal handler issues
The calling thread of CreateProcess can be in any library and
can have arbitrary signal masks and handlers.

We now save the caller's mask and  block all signals before forking.
After fork:
- child resets the handlers and unblocks all signals.
- parent restores the caller's original signal mask.
2015-07-02 11:28:06 +02:00
Bernhard Miklautz
ab8d83c8fc winpr/thread: fix test compilation on windows
Use DWORD instead of QWORD.
2015-06-22 19:09:59 +02:00
Emmanuel Ledoux
de1a21eadd winpr-thread: added HP's copyright 2015-05-27 18:24:56 +02:00
Emmanuel Ledoux
206714a270 winpr-thread: thread_list's synchronization based on a pthread_cond_t 2015-05-27 18:15:17 +02:00
Emmanuel Ledoux
f74cd12df2 winpr-thread: a better error message and comments about thread_list 2015-05-26 18:15:57 +02:00
Emmanuel Ledoux
56f34582c7 winpr-thread: added an assertion to enforce that thread_list is correctly set 2015-05-26 17:55:27 +02:00
Emmanuel Ledoux
93127e0a7a winpr-thread: thread_list's synchronization based on an Event 2015-05-26 17:40:34 +02:00
Emmanuel Ledoux
f94ab0033b winpr-thread: better error message upon a failure of TestThreadExitThread 2015-05-22 19:17:30 +02:00
Emmanuel Ledoux
6f5de27081 winpr-thread:
- added the unit test: TestThreadExitThread
  - fix: ensure thread_list to be up to date before to call ExitThread()
  - possibly resolved: Problems with serial redirection #2389
2015-05-22 18:28:10 +02:00
Marc-André Moreau
b9c1cddc2e Merge pull request #2583 from bceverly/OpenBSD-cleanup
Two minor source code changes to remove warnings
2015-05-21 10:17:54 -04:00
Bryan Everly
a3a3efe31e Fixed mistake with bitwise operator in previous two commits 2015-05-20 12:17:05 -04:00
Bryan Everly
80af54b169 Moved thread code to OpenBSD only 2015-05-20 10:52:24 -04:00
Hardening
f8120919af Add checks for some XXX_New and XXX_Add functions
Based on PR #2616
2015-05-18 11:28:00 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Norbert Federa
c77def3048 Fix unchecked CreateMutex calls 2015-05-07 13:27:49 +02:00
Bryan Everly
9865854f3c Simplified random byte stream generation code to use SSL RAND_bytes() and also eliminated two more compiler warnings. 2015-05-05 12:33:44 -04:00
Bernhard Miklautz
a8c44f15c0 winpr: small fixes and cleanups
Update the pull request and integrate the latest comments and
suggestions.

* TestLibrary*: fix typo in error message
* TestPipeCreateNamedPipeOverlapped: free possibly allocated memory
* smartcard_pcsc.c: format fix
* process.c: add missing NULL check
* MessageQueue.c: delete possibly initialized critical section on error
2015-04-08 11:34:37 +02:00
Bernhard Miklautz
850de59b55 winpr: add checks for *alloc
Add missing checks if memory allocation was successful. Also adapt
caller(s) when possible.
2015-04-08 11:34:37 +02:00
Armin Novak
b3ea02a777 Removed INVALID_HANDLE_VALUE from types not using it. 2015-03-31 15:18:45 +02:00
Armin Novak
afe8bd2a86 Fixed missing checks for invalid handle. 2015-03-31 15:18:45 +02:00
Bernhard Miklautz
1d7b3694a9 Integrate feedback from pull request (#2492)
* shell: add missing NULL checks
* thread: handle case where HAVE_EVENTFD_H isn't defined
* wlog: return NULL instead of 0
* wlog: use g_RootLog instead of WLog_GetRoot
  otherwise a new root might be initialized on uninit
* indentation and style fixes
2015-03-25 17:38:21 +01:00
Bernhard Miklautz
3c7662517c hardening
Start to add missing checks for:
* *alloc
* *_New
2015-03-25 17:38:21 +01:00
David FORT
52bd4469d9 Make handle operations static
This patch moves the handle operations in a static struct.
2015-03-16 10:31:26 +01:00
Armin Novak
9153af6a3e Using new handle cleanup structure 2015-03-11 17:57:01 +01:00
Armin Novak
465d8ec688 Using new handle cleanup structure 2015-03-11 17:57:01 +01:00
Bernhard Miklautz
582856d142 winpr/process: handle pids <= 0
TerminateProcess shouldn't call kill if the PID is <=0 because this has
unwanted effects (and is not what TerminateProcess should do):

* with PID == 0 any process in the same process group gets the signal
  sent
* with PID == -1 *every* processes that the running users has
  permissions to gets the signal sent
* with PID < -1 the process within the same process group and -PID gets
  the signal send

For more details see kill(2).
2015-02-09 14:07:14 +01:00
Emmanuel Ledoux
4aeaffa286 libwinpr: better indentation 2015-01-28 12:43:20 +01:00
Emmanuel Ledoux
ab4a744b08 libwinpr: attempt to fix TerminateThread(...).
The following sequence should not hang forever anymore: TerminateThread(thread, 0); WaitForSingleObject(thread, INFINTE);
2015-01-27 21:05:40 +01:00
Armin Novak
122d1c43f4 Prettiefied WLog messages. 2015-01-20 11:04:23 +01:00
Armin Novak
44904ad5d2 Fixed a race condition at thread creation
The thread structure was incorrectly updated after the thread
function was already running. This caused a race condition with
thread exiting. When the thread function returned before the structure
was correctly updated, the exit routine cleaned up the handle as
it was incorrectly marked not started.
2015-01-16 11:26:31 +01:00
Armin Novak
4d8c91b0fe Fixed missing declarations. 2014-12-07 01:15:49 +01:00
Armin Novak
8a6c4396b2 Fixed memory leak. 2014-12-07 01:04:30 +01:00
Marc-André Moreau
6ccce86140 Merge branch 'master' of github.com:FreeRDP/FreeRDP
Conflicts:
	winpr/libwinpr/thread/thread.c
2014-12-03 10:10:50 -05:00
Martin Haimberger
7897de057b fixed compiler warning 2014-12-02 00:36:46 -08:00
Martin Haimberger
fa6d551676 changed processhandle handling to new system 2014-12-02 00:08:10 -08:00
Martin Haimberger
128458d380 fixing memoryleak by introducing a nonehandle
In CreateProcess the non functional thread
handle was leaked.
2014-12-01 23:53:58 -08:00
Marc-André Moreau
0818846d7c winpr: fix build warnings 2014-11-21 15:12:49 -05:00
Marc-André Moreau
871339da88 Merge branch 'master' of github.com:awakecoding/FreeRDP
Conflicts:
	winpr/libwinpr/thread/thread.c
2014-11-20 11:51:18 -05:00
Marc-André Moreau
2afcac7838 libwinpr-thread: fix non-blocking internal pipe-based event on OS X 2014-11-20 11:48:02 -05:00
Armin Novak
7b9bf1a504 Fixed uninitialized variable. 2014-11-16 17:02:36 +01:00
Armin Novak
fb5d20f338 Fixed NULL pointer dereference. 2014-11-16 16:51:04 +01:00
Armin Novak
53450b6423 Checking setgid before calling initgroups now. 2014-11-16 15:59:26 +01:00
Armin Novak
51cb07b0f4 Fixed use after free. 2014-11-16 15:21:13 +01:00