|
|
Log in / Subscribe / Register

Memory-safe C code

Memory-safe C code

Posted Nov 16, 2025 20:26 UTC (Sun) by khim (subscriber, #9252)
In reply to: Memory-safe C code by alx.manpages
Parent article: Rust in Android: move fast and fix things (Google Security Blog)

> Agree. Why did you assume it wouldn't handle memory allocations? :-)

Because these are, essentially, impossible to track without extra viral markup everywhere. Even a simple call to strstr leaves you with a dilemma of validness of returned pointer (is its validity tied to needle or to haystack?) and, as an added bonus, it also gives you a write access to the buffer than sometimes could and sometimes couldn't be modified.

These problems are not impossible to track… but getting people to add (and correctly add!) such markup sounds like a more-or-less impossible thing to do.

Essentially: it's hard but possible to add all these things to the language. But after you'll do that you'll need to rewrite almost everything anyway… and if you are doing it why not pick a nicer, more modern, language?


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds