frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Linux Kills Strncpy

https://smist08.wordpress.com/2026/06/25/linux-kills-strncpy/
19•ingve•2d ago

Comments

jmclnx•1h ago
As I expected, this is about removing strncpy() from the Linux Kernel, not glib.

Removing strncpy() from glib would be awful for applications :)

79a6ed87•1h ago
Confusion comes from Linux being used as a replacement term for any distro
mattst88•54m ago
I suspect you mean glibc.
tom_•58m ago
Previously: https://news.ycombinator.com/item?id=48612943
uecker•36m ago
BTW: I was experimenting a bit more with string and string view (strv) types in my e toy library: https://codeberg.org/uecker/noplate/

The tests are maybe better examples than those on godbolt. https://codeberg.org/uecker/noplate/src/branch/main/tests/st...

whytevuhuni•18m ago
How does strv2cstr work? I assume it doesn't allocate, so not sure how it can add a null terminator.
uecker•12m ago
It will not add one if there isn't one already. (I should probably rename this function, work in progress..). But the type is an array of the correct length.
rho138•23m ago
When a wordpress site has more ads than arstechnica.
rakel_rakel•23m ago
Not going with something already widely deployed (like strlcpy), which could also be used in userland (strscpy can't, it's return value in case of failure is out of scope) is exactly what I would expect from Linux. You do you!
okl•12m ago
strncpy was originally used to write into fixed length buffers[1]. This becomes obvious when considering the padding behavior, as described in the C standard[2]: "If the array pointed to by s2 is a string that is shorter than n characters, null characters are appended to the copy in the array pointed to by s1, until n characters in all have been written."

strlcpy, often touted as a replacement, does not elicit the padding behavior but has another flaw: It is supposed to return the length of the string it tried to create, for example, so the user can call realloc without calling strlen again.[3] However, this final "strlen-tail" in strlcpy isn't bounded by the size parameter which describes dest, not src.

While strscpy is a marked improvement, there is still something to be careful about: It can read past the end of the src-buffer, when sizeof src < sizeof dest and src is not nul-terminated.[4] (Set the count argument to something like min(sizeof dest, sizeof src) to avoid that).

--

[1] - https://softwareengineering.stackexchange.com/a/438090

[2] - https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf, 7.26.2.5 p. 3

[3] - https://manpages.debian.org/jessie/libbsd-dev/strlcpy.3.en.h...

[4] - https://manpages.debian.org/testing/linux-manual-4.8/strscpy...

wpollock•11m ago
This article is a bit misleading. Linux kernel programming uses C, but not the C standard library and never has. The string functions discussed here are "helper" functions included in the kernel and are not part of the standard library.

The C standard library doesn't have strscpy or the others; it still has strncpy.

parasti•9m ago
Starting with "The C string library" made me instantly tune out. C has a standard library, which has some string-related functions. There is no "C string library".

Librepods: AirPods liberated from Apple's ecosystem

https://github.com/librepods-org/librepods
82•rbanffy•1h ago•4 comments

5k menus from the New York Public Library’s Buttolph Collection (1880-1920)

https://pudding.cool/2026/06/menu-story/
275•xbryanx•5h ago•72 comments

I used Claude Code to get a second opinion on my MRI

https://antoine.fi/mri-analysis-using-claude-code-opus
185•engmarketer•3h ago•291 comments

Semgrep: GLM 5.2 beats Claude in our Cyber Benchmarks

https://semgrep.dev/blog/2026/we-have-mythos-at-home-glm-52-beats-claude-in-our-cyber-benchmarks/
42•jms703•2h ago•12 comments

TOP500 at ISC'26: We Have a New Number 1 – By George Cozma

https://chipsandcheese.com/p/top500-at-isc26-we-have-a-new-number
18•rbanffy•51m ago•7 comments

Tokenmaxxing is dead, long live tokenmaxxing

https://12gramsofcarbon.com/p/agentics-tech-things-tokenmaxxing
69•theahura•4h ago•85 comments

The Boeing 747 begins its final descent

https://www.theatlantic.com/magazine/2026/07/boeing-747-retirement/687304/
77•dbl000•3d ago•68 comments

Working around dragons with the Lemote Yeeloong laptop and OpenBSD

http://oldvcr.blogspot.com/2026/06/working-around-dragons-with-lemote.html
60•zdw•3h ago•12 comments

Computer-Aided Language Development in Nonspeaking Children (1968) [pdf]

https://archive.org/details/colby1968-computer-aided-language-development-in-non-speaking-children
10•dang•1h ago•0 comments

Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch

https://github.com/JustVugg/nanoeuler
8•vforno•51m ago•1 comments

Show HN: Zanagrams

https://zanagrams.com/
101•pompomsheep•5h ago•34 comments

Historical memory prices 1960-2026

https://dam.stanford.edu/memory-prices.html
30•vga1•1h ago•6 comments

Examining circuit boards from the Space Shuttle's I/O Processor

https://www.righto.com/2026/06/space-shuttle-io-processor-boards.html
60•pwg•4h ago•12 comments

Ford rehires 'gray beard' engineers after AI falls short

https://techcrunch.com/2026/06/28/ford-rehires-gray-beard-engineers-after-ai-falls-short/
56•rbanffy•53m ago•26 comments

Daisugi, the Japanese technique of growing trees out of other trees (2020)

https://www.openculture.com/2020/10/daisugi.html
71•MaysonL•4h ago•21 comments

The cost YAGNI was never about

https://newsletter.kentbeck.com/p/the-cost-yagni-was-never-about
64•kiyanwang•1h ago•42 comments

A way to exclude sensitive files issue still open for OpenAI Codex

https://github.com/openai/codex/issues/2847
158•pikseladam•8h ago•104 comments

The curious case of the disappearing Polish S (2015)

https://aresluna.org/the-curious-case-of-the-disappearing-polish-s/
186•colinprince•7h ago•54 comments

The MUMPS 76 Primer – anniversary edition

https://github.com/rochus-keller/MUMPS/blob/main/docs/MUMPS_Primer.adoc
59•Rochus•7h ago•26 comments

Show HN: DRM-Free Books

https://frequal.com/Perspectives/DrmFreeAuthors.html
32•TeaVMFan•3h ago•11 comments

Programmable Probabilistic Computer with 1M p-bits

https://arxiv.org/abs/2606.25313
30•rbanffy•4h ago•0 comments

Show HN: Bash4LLM+ – A lightweight, dependency-free Bash wrapper for LLM APIs

https://github.com/kamaludu/bash4llm/
6•kamaludu•46m ago•3 comments

More evidence is consistent with possible ancient life on Mars (2025)

https://www.cbc.ca/radio/quirks/more-evidence-of-life-on-mars-but-still-no-life-1.7649645
39•pseudolus•8h ago•55 comments

The KIDS Act would require age checks to get online

https://www.eff.org/deeplinks/2026/06/kids-act-would-require-age-checks-get-online
178•bilsbie•8h ago•186 comments

EU to legislate about Chat Control behind closed doors

https://www.patrick-breyer.de/en/double-threat-to-private-communications-undemocratic-chat-contro...
474•NeutralForest•5h ago•275 comments

The US Used to Demand the Best Tech. Now We Ban It

https://www.pcmag.com/opinions/the-us-used-to-demand-the-best-tech-now-we-ban-it
22•mwexler•1h ago•14 comments

Show HN: Appaca – AI Workspace for Operators

https://www.appaca.ai/
8•susros•2d ago•6 comments

Michigan bill would bar employers from requiring after-hours coms with workers

https://www.cbsnews.com/detroit/news/workplace-boundaries-act-employees-after-hours/
196•cebert•5h ago•137 comments

Marfa Public Radio Puts You to Sleep

https://www.marfapublicradio.org/podcast/marfa-public-radio-puts-you-to-sleep
373•reaperducer•18h ago•114 comments

Trade, merchants, and the lost cities of the Bronze Age (2019) [pdf]

https://keremcosar.uvacreate.virginia.edu/publications/BCCH-BronzeAgeTrade-qje.pdf
68•NaOH•5d ago•62 comments