Bug 198038 - c11 thrd_join function from libstdthreads seg faults.
Summary: c11 thrd_join function from libstdthreads seg faults.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: threads (show other bugs)
Version: 10.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-standards (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-25 16:47 UTC by Vineela
Modified: 2015-05-15 16:12 UTC (History)
1 user (show)

See Also:


Attachments
Check for NULL. (387 bytes, patch)
2015-02-25 17:50 UTC, Konstantin Belousov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vineela 2015-02-25 16:47:42 UTC
Thrd_join function from libstdthreads seg faults when second parameter res is passed as NULL. The function in thrd.c writes to res without null check. C11 std specifies the parameter can be null.
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2015-02-25 17:50:13 UTC
Created attachment 153532 [details]
Check for NULL.

Are you fine with the patch attached ?  Can you test it ?
Comment 2 Vineela 2015-02-26 06:05:14 UTC
Comment on attachment 153532 [details]
Check for NULL.

Patch is good. 
Tested. Works fine.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-02-26 09:42:11 UTC
A commit references this bug:

Author: kib
Date: Thu Feb 26 09:42:04 UTC 2015
New revision: 279318
URL: https://svnweb.freebsd.org/changeset/base/279318

Log:
  Check that the pointer to the thread return value is not NULL before
  dereferencing. NULL is allowed by C11 and must be handled.

  Reported and tested by:	Vineela <vineela_17@yahoo.com>
  PR:	198038
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Changes:
  head/lib/libstdthreads/thrd.c