public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* Some bugs
@ 2003-09-19 19:19 fake
  0 siblings, 0 replies; only message in thread
From: fake @ 2003-09-19 19:19 UTC (permalink / raw)
  To: rpj, pthreads-win32

I've found a couple of bugs in pthread-win32. I can't tell you the exact
source files/lines 'cause my job requires me not to look at the sources, and
I found the bugs during the reverse-engineerign of your official binaries
(hey, just doin' my job). Anyway:
 - sched_setscheduler: you never CloseHnalde tyhe handle obtained through
OpenProcess:

  push    esi
  mov     esi, [esp+pid]
  test    esi, esi
  jz      short loc_10005795
  call    ds:GetCurrentProcessId
  cmp     esi, eax
  jz      short loc_10005795
  push    esi             ; dwProcessId
  push    0               ; bInheritHandle
  push    PROCESS_SET_INFORMATION ; dwDesiredAccess
  call    ds:OpenProcess
  test    eax, eax
  jnz     short loc_10005795 ; <<< leak!!
  call    ds:GetLastError
  mov     esi, eax
  sub     esi, 5
  neg     esi
  sbb     esi, esi
  and     esi, 2
  inc     esi
  call    ds:_errno
  mov     [eax], esi
  or      eax, -1
  pop     esi
  retn ;
; -------------------------------------------------------------

loc_10005795:
  mov     eax, [esp+policy]
  test    eax, eax
  jz      short loc_100057AE
  call    ds:_errno
  mov     dword ptr [eax], 40 ; ENOSYS
  or      eax, -1         ; failure
  pop     esi
  retn
; -------------------------------------------------------------

loc_100057AE:
  xor     eax, eax        ; success
  pop     esi
  retn

 - you seem to be declaring all functions __declspec(dllimport) even for the
build of the dll itself. This generates kinda weird binaries, with all
functions residing at the lowest offsets of .text and containing just jmps
to hugher addresses in the segment. The M$ linker generatse a warning about
it ("local name 'XXX' imported", or something like that), and you shouldn't
ignore it. Nothing ciritcal, but it just doesn't look right

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-19 19:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-19 19:19 Some bugs fake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).