WineHQ
Bug Tracking Database – Bug 34211

 Bugzilla

 

Last modified: 2013-11-15 13:40:31 UTC  

strncpy C library function doesn't compliant C standard.

Bug 34211 - strncpy C library function doesn't compliant C standard.
strncpy C library function doesn't compliant C standard.
Status: CLOSED FIXED
AppDB: Show Apps affected by this bug
Product: Wine
Classification: Unclassified
Component: msvcrt
1.7.0
x86 Linux
: P2 normal
: ---
Assigned To: Mr. Bugs
: download, patch, testcase
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-08-05 15:35 UTC by Alvaro Nieto
Modified: 2013-11-15 13:40 UTC (History)
1 user (show)

See Also:
Regression SHA1:
Fixed by SHA1: e3e12845572dce7b35660814c44dedf069de1dfb
Distribution: ---
Staged patchset:


Attachments
Program that shows the bug and patch that solves it (810 bytes, application/zip)
2013-08-05 15:35 UTC, Alvaro Nieto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvaro Nieto 2013-08-05 15:35:09 UTC
Created attachment 45514 [details]
Program that shows  the bug and patch that solves it

From standard;

"If the array pointed to by s2 is a string that is shorter than n bytes, null bytes shall be appended to the copy in the array pointed to by s1,until n bytes in all are written"

The attached code doesn't prints anything in Windows and Linux but prints in wine because wine's strncpy doesn't append null bytes.

Also I've included a patch that solves the problem.
Comment 1 Austin English 2013-08-05 17:32:42 UTC
Patches should be sent to wine-patches@winehq.org. See http://wiki.winehq.org/SubmittingPatches
Comment 2 Bruno Jesus 2013-08-05 18:46:46 UTC
>  for(i=0; i<sizeof(src); i++)
>  ...
>  for(i=sizeof(src)+1; i<len; i++)

I think you need strlen instead of sizeof, but IMO there seems to be an easier way to do it.
Comment 3 Bruno Jesus 2013-08-16 14:43:34 UTC
Patch commited, thanks for your work.

http://source.winehq.org/git/wine.git/?a=commit;h=e3e12845572dce7b35660814c44dedf069de1dfb
Comment 4 Alexandre Julliard 2013-08-30 13:06:10 UTC
Closing bugs fixed in 1.7.1.
Comment 5 Alexandre Julliard 2013-11-15 13:40:31 UTC
Removing 1.6.x milestone from bugs included in 1.6.1.


Privacy Policy
If you have a privacy inquiry regarding this site, please write to [email protected]

Hosted By CodeWeavers