This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/17609] abnormal behavior for strncpy


https://sourceware.org/bugzilla/show_bug.cgi?id=17609

--- Comment #2 from Wissam Ghammashi <wissamg at gmail dot com> ---
I wrote a function that removes the '<' and '>' from email address, using
strchr, strrchr and strncpy.
And come over a bad behavior for strncpy:
I'm copying " <wis.test@hmail.vic.local.pinecoat.com>"
               ^From here                          ^Till here
             ^To here
and I'm getting the following result:
            "wis.test@hmail.vic.local.pineaoat.com"
watch the the word "pinecoat" was changes to "pineaoat"

I'm using CentOS 6.6 with:
glibc-2.12-1.149.el6.x86_64
gcc-c++-4.4.7-11.el6.x86_64
gcc-4.4.7-11.el6.x86_64
libgcc-4.4.7-11.el6.x86_64

The code sample is attached and this behavior does not happen with memcpy.


Thanks a lot,
WissaM

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]