Skip to main content
17 events
when toggle format what by license comment
Jan 30, 2024 at 6:01 answer added John Mashey timeline score: 3
May 9, 2022 at 22:59 audit Suggested edits
May 10, 2022 at 0:02
Apr 16, 2022 at 18:00 vote accept hyde
Apr 15, 2022 at 22:20 answer added njuffa timeline score: 8
Apr 14, 2022 at 0:00 history tweeted twitter.com/StackSoftEng/status/1514393003066109954
Apr 13, 2022 at 12:56 answer added Doc Brown timeline score: 2
Apr 13, 2022 at 12:56 comment added Useless Although unfortunately the accepted answer is poor, and you should probably look at this one instead: stackoverflow.com/a/1454071/212858
Apr 13, 2022 at 12:54 answer added Useless timeline score: 2
Apr 13, 2022 at 12:41 comment added Stack Exchange Broke The Law Cross-site duplicate: stackoverflow.com/questions/1453876/…
Apr 13, 2022 at 7:10 comment added hyde Also, I'd like to explicitly state that this is not meant as any kind of criticism of strncpy, so please no arguing if strncpy is good or bad or ugly. It's different, which I hope I have sufficiently demonstrated in my question text, and I am asking, why is it different?
Apr 13, 2022 at 7:01 comment added hyde @Alexander Well, strncpy semantics are very different from all other "str" functions (including *scanf and fgets), don't you agree? Was short write vulnerability something that people were concerned about at the time strncpy was designed?
Apr 13, 2022 at 6:58 comment added Jörg W Mittag … of UTF-8 would have required prescience and/or time travel.
Apr 13, 2022 at 6:58 comment added Jörg W Mittag @gnasher729: The purpose of strncopy is to convert from a C-style string to a fixed-length record. In other words: the fact that the result isn't a C-style string is the whole point of this function in the first place. The same reason applies to your second criticism: if you convert a C-style string contain UTF-8 to a fixed-length record, there is no guarantee that the record boundary lines up with a character boundary (or a grapheme cluster boundary or a glyph boundary or any other kind of text boundary). Besides, strncopy predates UTF-8 by well over a decade, so making strncopy aware
Apr 13, 2022 at 6:37 comment added gnasher729 The fact that it creates a not-a-c-string when the buffer is not large enough makes it unusable. The fact that copying long utf-8 can result in illegal utf-8 is equally bad.
Apr 13, 2022 at 2:01 comment added Alexander Could you help us understand what you find so strange about this? The 0-initialization that strncpy does over strcpy is great. To not do so would be a "short write vulnerability" See developer.apple.com/library/archive/documentation/Security/… for details
Apr 12, 2022 at 22:23 answer added gnasher729 timeline score: -2
Apr 12, 2022 at 21:51 history asked hyde CC BY-SA 4.0