Giter Club home page Giter Club logo

Comments (6)

l2dy avatar l2dy commented on September 4, 2024 1

Sure. Closing this issue then. Thanks for taking a look!

from yash.

magicant avatar magicant commented on September 4, 2024

Thanks for the report, but I have difficulty interpreting the message from the address sanitizer.
The third parameter to the wcsnrtombs function is of type size_t, which is an unsigned integer and can't be negative.
The parameter specifies the maximum number of characters to be converted, which is irrelevant to the actual size of arrays involved. Maybe the sanitizer is incorrectly configured to perform some check about this parameter?

PS: To print a size_t value, you should be using %zu rather than %ld.

from yash.

l2dy avatar l2dy commented on September 4, 2024

You are right. After further investigation, this seems to be a bug in AddressSanitizer. google/sanitizers#1524

However, this makes me wonder if wcsrtombs should be used instead when size is not specified. We don't have a buffer as big as Size_max anyway, and size_t len is still there to prevent buffer overflow. Why use such a large number here?

from yash.

magicant avatar magicant commented on September 4, 2024

Defining sb_wcscat as a special case of sb_wcsncat is much simpler than defining them as separate functions that are very similar but differ only in one line that calls either wcsrtombs or wcsnrtombs.

sb_wcscat is defined as: https://github.com/magicant/yash/blob/2e02670ad531ea8ac445217ce70d32915c736709/strbuf.h#L322C1-L328

from yash.

l2dy avatar l2dy commented on September 4, 2024

Defining sb_wcscat as a special case of sb_wcsncat is much simpler than defining them as separate functions that are very similar but differ only in one line that calls either wcsrtombs or wcsnrtombs.

Yes, but we already have sb_wcscat and malloc_wcstombs for systems without wcsnrtombs anyway. Could they be enabled on all systems?

yash/strbuf.c

Lines 233 to 236 in 2e02670

#if !HAVE_WCSNRTOMBS
wchar_t *sb_wcscat(xstrbuf_T *restrict buf,
const wchar_t *restrict s, mbstate_t *restrict ps)
{

from yash.

magicant avatar magicant commented on September 4, 2024

Hmm, I don't want to bloat the binary just to make the misbehaving analyzer happy.

from yash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.