<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to bugs</title><link href="https://sourceforge.net/p/threads/bugs/" rel="alternate"/><link href="https://sourceforge.net/p/threads/bugs/feed.atom" rel="self"/><id>https://sourceforge.net/p/threads/bugs/</id><updated>2001-10-12T19:37:17Z</updated><subtitle>Recent changes to bugs</subtitle><entry><title>Program exit</title><link href="https://sourceforge.net/p/threads/bugs/3/" rel="alternate"/><published>2001-10-12T19:37:17Z</published><updated>2001-10-12T19:37:17Z</updated><author><name>Bjarne Orn Hansen</name><uri>https://sourceforge.net/u/hanseno/</uri></author><id>https://sourceforge.netd51bc064acf15af6783fcb8c94255e381eff1ae4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;When a thread uses global semaphores, mutex or &lt;br /&gt;
condition varibles and is not finished, and not &lt;br /&gt;
detached when the main program exits.  It segfaults &lt;br /&gt;
or hangs the main program.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Thread collition</title><link href="https://sourceforge.net/p/threads/bugs/2/" rel="alternate"/><published>2001-10-07T13:20:29Z</published><updated>2001-10-07T13:20:29Z</updated><author><name>Anonymous</name><uri>https://sourceforge.net/u/userid-None/</uri></author><id>https://sourceforge.netd0edb6a49f5e737cb72e6e454efb1f9fedbc3d00</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Two simultaneous threads will collide, if run &lt;br /&gt;
extensively and using the standard template library.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Buffer overflow risk</title><link href="https://sourceforge.net/p/threads/bugs/1/" rel="alternate"/><published>2001-07-18T17:28:18Z</published><updated>2001-07-18T17:28:18Z</updated><author><name>Wolfgang Wieser</name><uri>https://sourceforge.net/u/wwieser/</uri></author><id>https://sourceforge.netf958d9e8479fe1b32a33dd98651f5fda9d24664a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi guys, &lt;/p&gt;
&lt;p&gt;while looking at the threads source code in order to &lt;br /&gt;
decide whether to use it for a project on a GPL'ed &lt;br /&gt;
network server a bug popped to my eyes: &lt;/p&gt;
&lt;p&gt;-------&amp;amp;lt;shared.C&amp;amp;gt;---------&lt;br /&gt;
void shared_mem::change_proj(const char *p_root)&lt;br /&gt;
{&lt;br /&gt;
strncpy( _key_root,p_root,79 );&lt;br /&gt;
}&lt;br /&gt;
---------------------------&lt;br /&gt;
...is unsafe because the strncpy() copies just the &lt;br /&gt;
first 79 bytes leavind the dest string unterminated &lt;br /&gt;
in case the source is longer. &lt;br /&gt;
In combination with...&lt;br /&gt;
---------&amp;amp;lt;shared.C&amp;amp;gt;-----------&lt;br /&gt;
int shared_mem::create_proj(const char *p_id)&lt;br /&gt;
{&lt;br /&gt;
int fd;&lt;br /&gt;
&amp;amp;gt;  string s = _key_root;&lt;br /&gt;
sto_iterator i;&lt;br /&gt;
-----------------------------&lt;br /&gt;
...this is unsafe as the string assignment relies &lt;br /&gt;
on proper termination. &lt;/p&gt;
&lt;p&gt;BTW, I really don't understand why you're using a &lt;br /&gt;
damn 80 char limit on _key_root. If you really have &lt;br /&gt;
to use a limit, then I would appreciate a &lt;br /&gt;
#define or const int for the limit. &lt;br /&gt;
Maybe you should also check the calls to strcpy() &lt;br /&gt;
in mutex.C, cond.C, semaphore.C: &lt;br /&gt;
Why not use something like&lt;br /&gt;
------&amp;amp;lt;snip&amp;amp;gt;-------&lt;br /&gt;
void semaphore::project_part(const char *p_part)&lt;br /&gt;
{&lt;br /&gt;
if(s_project)  delete[] s_project;&lt;br /&gt;
size_t len = p_part ? strlen(p_part) : 0;&lt;br /&gt;
s_project = new char[len+1];&lt;br /&gt;
*s_project='\0';&lt;br /&gt;
if(p_part)  strcpy(s_project,p_part);&lt;br /&gt;
}&lt;br /&gt;
----------------&lt;br /&gt;
(assuming that the s_project pointer may change and &lt;br /&gt;
the function is not critical to runtime efficiancy.) &lt;/p&gt;
&lt;p&gt;Regards, &lt;br /&gt;
W. Wieser&lt;/p&gt;
&lt;p&gt;Please drop me an e-mail to &lt;br /&gt;
wwieser@users.sourceforge.net when you have read &lt;br /&gt;
this as I don't know if you're using the bug tracking &lt;br /&gt;
system. &lt;/p&gt;&lt;/div&gt;</summary></entry></feed>