logoalt Hacker News

Linux Eliminates the Strncpy API After Six Years of Work, 360 Patches

76 pointsby simonpureyesterday at 8:59 PM47 commentsview on HN

Comments

lambdaonetoday at 12:39 AM

This sort of boring grind is where the real work of systems engineering is done. Big infrastructure projects like this work on making the Linux kernel more reliable while still keeping it workable throughout the process move on the scale of decades, not months.

senfiajyesterday at 11:42 PM

I wonder, why not use a string buffer paired with its length? For example, maybe use struct that has char pointer, and 2 ints (occupied length + total buffer length). Almost like c++'s std::string. This null terminator thing really sucks, it's potentially insecure and often unperformant.

show 3 replies
D-Codertoday at 12:30 AM

Note that "360 Patches" is 360 uses of strncpy that have been removed, not necessarily bugs.

mrlonglongyesterday at 9:30 PM

the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.

show 6 replies
PlunderBunnyyesterday at 9:40 PM

I worked on a Win32 app that used space-padded strings, i.e. the destination string was padded with spaces, but there was still a null on the last byte. You had to use special versions of the string functions for length, copy etc.

I’m not sure why this was - the source base was so old it might have had its origins in Pascal struct behaviour.

show 3 replies
naturalmovementyesterday at 10:34 PM

A reminder that we've had strlcpy[1] for ~ 30 years but it was never accepted into the Linux world because of typical petty open source bullshit. This is why we can't have nice things.

[1] https://man.openbsd.org/strlcpy

show 2 replies
larodiyesterday at 9:35 PM

Wonder when is someone going to brave and fork the linux kernel and try to ffwd it with automatic programming.

show 1 reply