Commit Graph

117 Commits

Author SHA1 Message Date
Norbert Federa
c16bee759f winpr: several pool and synch fixes
pool:
- the winpr implementation fallback was not used on older windows editions
- drop useless and conflicting TP_CALLBACK_ENVIRON_V3
- fix race conditions by using use proper one-time initialization
- on win32 WinPR tried to load several pool/callback_environment functions
  from kernel32.dll but since these are defined as inline functions in the
  windows headers, no windows edition has ever exported them in any dll.
- removed callback_environment.c and added corresponding static inline
  function to pool.h
- fix segfault in TestPoolWork: CloseThreadpoolWork() must not be called
  if there is a cleanup group associated with the work object since calling
  CloseThreadpoolCleanupGroupMember() already releases the work object

sync:
- The windows headers incorrectly define InitializeCriticalEx support if
  _WIN32_WINNT >= 0x0403 instead of >= 0x0600 (Vista)
- created a compatible define to deal with this issue
2016-06-04 17:09:48 +02:00
Norbert Federa
e718fb324b fix race conditions, tests and some invalid return values
Since the current winpr implementation for overlapped operations is
incomplete and buggy, all affected functions will now fail if they are
called with a set FILE_FLAG_OVERLAPPED flag or a non-null pointer to
a OVERLAPPED structure.

winpr/nt:
- use proper one-time initialization on win32
- fix TestNtCreateFile
- fix broken/incomplete _RtlAnsiStringToUnicodeString
- unimplemented functions return appropriate error codes

winpr/pipe:
- improved TestPipeCreateNamedPipe
- rewrite the completely broken TestPipeCreateNamedPipeOverlapped test

rdtk:
- improve test and don't blindly return success

winpr/synch:
- fix race condition in TestSynchTimerQueue

winpr/ssspi:
- fix TestEnumerateSecurityPackages printf output
- fix TestQuerySecurityPackageInfo printf output

winpr/environment:
- fix GetEnvironmentStrings printf output

winpr/comm:
- unimplemented functions return appropriate error codes

winpr/io:
- unimplemented functions return appropriate error codes

winpr/thread:
- implement SwitchToThread() via sched_yield()
2016-06-01 16:26:26 +02:00
Marc-André Moreau
915b9a15b1 Merge branch 'master' of github.com:FreeRDP/FreeRDP
Conflicts:
	winpr/libwinpr/bcrypt/CMakeLists.txt
2016-05-11 11:05:17 -04:00
Marc-André Moreau
cedf6d98e2 freerdp: more UWP porting 2016-03-29 20:34:52 -04:00
Marc-André Moreau
4d629a7999 freerdp: UWP porting 2016-03-29 16:03:15 -04:00
Bernhard Miklautz
b184f58c1b winpr/TestFileGetStdHandle: rename variable stdout
stdout shouldn't be used as variable name (can't even be used on
windows).
2016-03-29 18:14:16 +02:00
Martin Fleisz
80cd64732f Merge pull request #3164 from akallabeth/windows_UnixChangeFileMode
Implemented UnixChangeFileMode for windows.
2016-03-16 15:19:11 +01:00
Armin Novak
3d23a772f6 Updated ConvertToUnicode return check. 2016-03-16 13:08:06 +01:00
Marc-André Moreau
ceefc4b099 Merge branch 'master' of github.com:FreeRDP/FreeRDP 2016-03-07 10:19:50 -05:00
Armin Novak
34b12362cb Fixed FreeBSD support for filetime settings. 2016-03-06 15:01:58 +01:00
Norbert Federa
ef4b29e5b3 ConvertFromUnicode fixes and misc hardening
- Added missing ConvertFromUnicode checks
- If ConvertToUnicode allocates memory, guarantee the null termination
  similar to ConvertFromUnicode's implementation
- Fixed some TestUnicodeConversion.c CTest return values
- Added some CTests for ConvertFromUnicode and ConvertToUnicode
- Misc code and protocol hardening fixes in the surrounding code regions
  that have been touched
2016-03-03 16:56:19 +01:00
Armin Novak
c74e37dbfd Implemented UnixChangeFileMode for windows. 2016-03-02 09:41:47 +01:00
Armin Novak
98d4a9347a Added support for android SetFileTime.
Deactivated libjpeg support for android.
2016-02-26 12:27:59 +01:00
Armin Novak
5537230298 Fixed missing iOS UTIME_OMIT. 2016-02-26 11:43:54 +01:00
Armin Novak
436be2441a Implemented SetFileTime 2016-02-26 11:00:17 +01:00
Martin Fleisz
1b881e47d3 winpr/file: Add missing include (io.h) for windows builds 2016-02-23 09:55:55 +01:00
Marc-André Moreau
bfca674f2d Merge branch 'master' of github.com:FreeRDP/FreeRDP 2016-02-05 11:39:45 -05:00
Armin Novak
a1617c734c Fixed unused check. 2016-02-03 11:22:27 +01:00
Armin Novak
9b160d4570 Fixed uninitialized value. 2016-01-15 09:33:21 +01:00
Bernhard Miklautz
06307f1ac1 winpr/file: disable buffering
When FILE streams are used per default buffering is enabled but
WriteFile/ReadFile shouldn't do any extra buffering.
2015-12-16 18:47:42 +01:00
Armin Novak
5b2f4f50a0 Fixed FILE* leak and EndOfFile settings. 2015-12-16 17:35:59 +01:00
Armin Novak
6010932984 Fixed possible race on file creation. 2015-12-14 09:32:42 +01:00
Armin Novak
f0e3a2d845 Added extended file seek tests. 2015-12-10 10:40:14 +01:00
Armin Novak
fe51dd1e10 Fixed logging, added file name. 2015-12-10 10:39:37 +01:00
Armin Novak
400d1b8b96 Fixed open mode for fdopen. 2015-12-10 10:37:44 +01:00
Armin Novak
19744f3bb8 Added additional file functions and tests. 2015-12-09 18:29:16 +01:00
Marc-André Moreau
c0c9c9353e winpr: more Win32 fixes 2015-11-25 14:41:32 -05:00
Bernhard Miklautz
0cdb4f7924 Fix compiler warnings
gcc (Debian 4.9.2-10) 4.9.2

winpr/libwinpr/thread/argv.c: In function ‘CommandLineToArgvA’:
winpr/libwinpr/thread/argv.c:94:6: warning: unused variable ‘index’ [-Wunused-variable]
  int index;

winpr/libwinpr/file/test/TestFileGetStdHandle.c: In function ‘TestFileGetStdHandle’:
winpr/libwinpr/file/test/TestFileGetStdHandle.c:44:2: warning: implicit
	declaration of function ‘CloseHandle’ [-Wimplicit-function-declaration]
  CloseHandle(stdout);
    ^
libfreerdp/codec/test/TestFreeRDPRegion.c: In function ‘test_norbert2_case’:
libfreerdp/codec/test/TestFreeRDPRegion.c:697:6: warning: unused variable ‘i’ [-Wunused-variable]
  int i;

channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_receive_format_list’:
channels/cliprdr/server/cliprdr_main.c:636:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
                        ^
channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_init’:
channels/cliprdr/server/cliprdr_main.c:1097:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
2015-11-09 19:26:34 +01:00
Martin Haimberger
925e4ea4d4 winpr/file: extend API
added windows code
fixed compiler issue
2015-09-15 04:14:30 -07:00
Bernhard Miklautz
074854735f winpr/file: extend API
Add function GetFileHandleForFileDescriptor to get
a file handle for a valid file descriptor.
2015-09-15 02:16:36 -07:00
Bernhard Miklautz
0d9dfb974d winpr/file: integrate pull request feedback
* simplify RemoveDirectory
* move std handle function into an extern C block
2015-09-10 11:50:10 +02:00
Bernhard Miklautz
0f5e7c60a7 winpr/file: don't close stdin/stdout/stderr
If the handle is closed stdin/stdout/stderr should be left open.
2015-09-09 17:07:40 +02:00
Bernhard Miklautz
8091530779 winpr/file: fix ios build
comm is only build on linux.
2015-09-09 17:07:13 +02:00
Bernhard Miklautz
6b52a2e5cc winpr/file: initial regular file support
Add initial support for "regular" files. First implemented call is
GetStdHandle to get stdin/stdout/stderr.
2015-09-09 16:47:03 +02:00
Bernhard Miklautz
204ae5462a winpr/file: refactoring
The used method for initalizing and registering the handle creators
had certain disadvantages like that it was necessary to have the creators
initialized before the first call to CreateFile. In case of comm it
wouldn't have been possible to open an comm port without calling any
other call related function first.
Now the handle creators are initialized the first time CreateFile is
called. This way it is also possible to ensure a certain order of the
handler invocations.

This commit also splits out the client side named pipe code from
the generic file handling (now called generic.c instead of file.c) and
uses the new handle creator infrastructure to register.
2015-09-09 15:48:59 +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
bf73f4e4f1 Fix unchecked strdups
* add missing checks
* adapt function return values where necessary
* add initial test for settings
2015-06-22 19:09:59 +02:00
Armin Novak
db7753bc8b Added RemoveDirectoryA, clean up test directories. 2015-06-09 13:16:28 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +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
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
552df08926 Implement ReadFile() and WriteFile() as handle operation 2015-03-16 21:29:19 +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
4fda6b1e5a Using new handle cleanup structure 2015-03-11 17:57:01 +01:00
Armin Novak
8848d1d1fa Using handle close callback now. 2015-03-11 15:10:52 +01:00
Armin Novak
cd1782efaa Fixed NULL pointer dereference. 2014-11-16 16:47:38 +01:00
Armin Novak
b22b897389 Reformatted changed files. 2014-09-09 16:32:22 +02:00