AW: [En-Nut-Discussion] NutThreadCreate - td_name safeguarding ?
Oliver Schulz
Oliver.Schulz at bong.de
Thu Dec 11 15:01:08 CET 2003
Hi Dave,
this bug is already fixed. Please use the latest thread.c (ver 1.3) from CVS!
If you cannot use CVS, please contact me for a complete snapshot of the CVS.
Regards,
Oliver.
> -----Ursprüngliche Nachricht-----
> Von: Dave Smart [mailto:Dave at Smart-Family.net]
> Gesendet: Donnerstag, 11. Dezember 2003 13:50
> An: En-Nut-Discussion at egnite.de
> Betreff: [En-Nut-Discussion] NutThreadCreate - td_name safeguarding ?
>
>
> NutOS 3.3.2.1:
>
> I momentarily forgot the rules, and found a small problem.
>
> I was calling NutThreadCreate with a rather long thread names
> as you see
> here -
> NutThreadCreate("SoundThread", SoundThread, arg, 768);
> NutThreadCreate("PowerThread", PowerThread, arg, 768);
>
> and when running a modification of the web server, I was
> getting string
> runaway -
> 37FC PowerThrGÍ7@ü4C?â ï¾Þ ï¾Þï¾Þï¾Þï¾Þd- 64 SLP 0CE2
> 3F43 37CD 721
> OK
> 34DF SoundThrû°4@ß1W?Ö ï¾Þ
> ï¾Þï¾Þï¾Þï¾Þ]UwòÎ̹¾=z¸tÓÔñzÿVËÚ·[ÀÜ){ç9
> 9n«zÛ÷]þ[²ú¹ßm»¯zW?oóÁ-Wwø±Þ~â©Fzr 64 SLP 0CD6 3F57 34B0 721 OK
>
> sys/thread.h defines the size of td_name
> u_char td_name[9];
>
> Then in the NutThreadCreate function, it is safely copying
> based on the
> sizeof the td_name
> ...
> memcpy(td->td_name, name, sizeof(td->td_name) - 1);
>
> but only if I have /correctly/ defined a short name. May I suggest an
> additional statement in NutThreadCreate -
> memcpy(td->td_name, name, sizeof(td->td_name) - 1);
> td->td_name[8] = '\0'; /* safeguard the name from runaway */
>
> which I applied to my source and it does what you would expect -
>
> 37F2 PowerThr 64 SLP 0CD8 3C1C 37C3 721 OK
> 34D5 SoundThr 64 RDY 0A79 0000 34A6 721 OK
>
> regards,
> Dave Smart
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
More information about the En-Nut-Discussion
mailing list