Comments (6)
ISO/IEC 9899:1999 (E) 7.24.6.3.2 "The mbrtowc function" seems unclear on this.
It would surprise me if people implemented it that way, as it contradicts expectations for e.g. strncmp()
or strncpy()
(i.e. your YMM example is AFAICT invalid for strncmp()
, but maybe not?).
Fixing this isn't hard, though it will introduce a bit of complexity and nastiness in this very core function.
Let's take a look at the common implementations.
from notcurses.
You are right. If interpreted as akin to strncmp
, it shouldn't be a problem. But because you can also give it invalid multibyte sequences and its supposed to return error values, I was under the impression n
is more a buffer length kinda parameter. I hardly ever use wchar_t
, so apologies, if this is a red herring.
from notcurses.
no, i appreciate filing the bug. i am not certain of my interpretation, and have wondered about this before (it also came up in a bug filed by @zhiayang a few weeks ago). we might end up naturally enforcing this as part of handling that request.
from notcurses.
here's an interesting link https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level#2__better_fortification_coverage
One example is
wcrtomb
, where glibc makes stronger assumptions about the object size passed than POSIX allowed. Specifically, glibc assumes that the buffer passed towcrtomb
is always at leastMB_CUR_MAX
bytes long. In contrast, the POSIX description makes no such assumption. Due to this discrepancy, any application that passed a smaller buffer would potentially makewcrtomb
overflow the buffer during conversion. Then the fortified version__wcrtomb_chk
aborts with a buffer overflow, expecting a buffer that isMB_CUR_MAX
bytes long. We fixed this bug in glibc-2.36 by making glibc conform to POSIX .
from notcurses.
I read this as that mbrtowc(&wc, gcluster, MB_LEN_MAX, &mbt);
used to be fine, but now is wrong or ?
from notcurses.
I read this as that
mbrtowc(&wc, gcluster, MB_LEN_MAX, &mbt);
used to be fine, but now is wrong or ?
nah, it was an error in the implementation of wcrtomb()
in glibc. just an interesting datum.
i think the Standard is fundamentally ambiguous here. i'd still like to go look at implementations, though that guarantees nothing about the future (your YMM example is very much the kind of thing i'm worried about).
from notcurses.
Related Issues (20)
- Possibility of refreshing terminfo cache? HOT 4
- Getting the new window size when receiving `NCKEY_RESIZE` HOT 1
- Resizing window causes ghost characters to remain HOT 9
- Builtin way to get "topmost plane containing coordinates"? HOT 6
- Non-user generated inputs on startup
- `ncplane_putnstr` doesn't fully respect the maximum number of bytes HOT 18
- amata_next diagnostics on startup
- input byte-limited versions of output functions HOT 6
- USAGE.md references non-existing constant `NC_FG_ALPHA_MASK` HOT 2
- Add node wrappers for node cli tools to use
- Add an option to disable the kitty background color avoidance feature
- API feels gimped, need ncplanes without parents HOT 2
- Check for <= 0 sorta fails because of unsigned int / int mismatch HOT 4
- add support for win32-input-mode HOT 6
- ncplane_puttext causes infinite plane resizing HOT 7
- fix up problems highlighted by clang-tidy-15
- Skipping prohibited unicode instead of erroring HOT 4
- parent not updating dimension when child forces parent to grow HOT 1
- notcurses-demo run under valgrind with early exit requires ctrl+c HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notcurses.