GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Rich Felker (dalias@hachyderm.io)'s status on Monday, 23-Jun-2025 11:42:42 JST Rich Felker Rich Felker

    TIL bash shell arithmetic does its operations as signed C integer arithmetic, so that overflow invokes undefined behavior. 🤡

    In conversation about 3 days ago from hachyderm.io permalink
    • Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 11:44:27 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      @dalias Well that's POSIX behavior: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_06_04
      In conversation about 3 days ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: pubs.opengroup.org
        Shell Command Language
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 11:48:13 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      • Haelwenn /элвэн/ :triskell:
      @dalias Although float can be allowed when it wouldn't change non-overflow results but I doubt most shells switch to a float.
      In conversation about 3 days ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Monday, 23-Jun-2025 11:48:42 JST Rich Felker Rich Felker
      in reply to
      • Haelwenn /элвэн/ :triskell:

      @lanodan It's not clear to me that the shell itself is permitted to have undefined behavior (which would include allowance to execute rm -rf /) just because the arithmetic expression would as a C expression. Even if this is permitted, it's a serious QoI and security fault since arithmetic is often evaluated from untrusted inputs.

      In conversation about 3 days ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Monday, 23-Jun-2025 11:49:50 JST Rich Felker Rich Felker
      in reply to
      • Haelwenn /элвэн/ :triskell:

      @lanodan The problem is not that it's semantically signed-integer but that it's implemented under the hood with C signed integers and no provisions for overflow checking or otherwise avoiding UB at the shell implementation layer.

      In conversation about 3 days ago permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      John Regehr (regehr@mastodon.social)'s status on Monday, 23-Jun-2025 11:52:13 JST John Regehr John Regehr
      in reply to

      @dalias for this same reason it used to be possible to terminate bash by dividing by zero in a bash script

      In conversation about 3 days ago permalink
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 11:52:25 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      @dalias So like it throwing an error when an overflow happens?
      Well… given it's UB shells could adopt that behavior.
      In conversation about 3 days ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Monday, 23-Jun-2025 11:53:23 JST Rich Felker Rich Felker
      in reply to
      • Haelwenn /элвэн/ :triskell:

      @lanodan No, it's just probably doing what they intended, silent wraparound. But the compiler could be "optimizing" it in fun ways or trapping and killing the shell (like if you turn on sanitizers), or whatever.

      In conversation about 3 days ago permalink
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 11:56:52 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      @dalias Yeah, would make sense for shells to avoid C's UB there, they're effectively given freedom as it is UB too but it doesn't means they have to propagate it to C.
      In conversation about 3 days ago permalink
    • Embed this notice
      GNU Too (gnu2@gnusocial.jp)'s status on Monday, 23-Jun-2025 11:59:42 JST GNU Too GNU Too
      in reply to
      @dalias lol nice!
      In conversation about 3 days ago permalink
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 19:01:41 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      • :umu: :umu:
      @a1ba @dalias That got dropped in modern C standards
      In conversation about 2 days ago permalink
    • Embed this notice
      :umu: :umu: (a1ba@suya.place)'s status on Monday, 23-Jun-2025 19:01:42 JST :umu: :umu: :umu: :umu:
      in reply to
      @dalias C still pretends there are machines that aren't two's complement :(
      In conversation about 2 days ago permalink
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Monday, 23-Jun-2025 19:11:51 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      • :umu: :umu:

      @a1ba @dalias It still entirely is like gcc/clang have -fwrap and -ftrap.

      And like, you don't really need to drop one's complement to get rid of UB, you could switch it to implementation-defined or 2+ acceptable behaviors.

      In conversation about 2 days ago permalink
    • Embed this notice
      :umu: :umu: (a1ba@suya.place)'s status on Monday, 23-Jun-2025 19:11:52 JST :umu: :umu: :umu: :umu:
      in reply to
      • Haelwenn /элвэн/ :triskell:
      @lanodan @dalias so it's not UB anymore
      In conversation about 2 days ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Monday, 23-Jun-2025 21:04:15 JST Rich Felker Rich Felker
      in reply to
      • :umu: :umu:

      @a1ba No, UB is not a consequence of not assuming 2s compl.

      In conversation about 2 days ago permalink
    • Embed this notice
      divVerent (divverent@misskey.de)'s status on Tuesday, 24-Jun-2025 20:22:05 JST divVerent divVerent
      in reply to
      • Haelwenn /элвэн/ :triskell:
      • :umu: :umu:
      • uis

      @uis@pone.social @a1ba@suya.place @dalias@hachyderm.io @lanodan@queer.hacktivis.me I am not a source. https://google.github.io/styleguide/cppguide.html "On Unsigned Integers" is.

      In conversation about a day ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Google C++ Style Guide
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      uis (uis@pone.social)'s status on Tuesday, 24-Jun-2025 20:22:06 JST uis uis
      in reply to
      • Haelwenn /элвэн/ :triskell:
      • divVerent
      • :umu: :umu:

      @a1ba @dalias @lanodan google banned unsigned integers in their codebase to detect integer overflow with ubsan.
      Source: @divVerent

      In conversation about a day ago permalink
    • Embed this notice
      divVerent (divverent@misskey.de)'s status on Tuesday, 24-Jun-2025 20:22:06 JST divVerent divVerent
      in reply to
      • Haelwenn /элвэн/ :triskell:
      • :umu: :umu:

      @a1ba@suya.place @lanodan@queer.hacktivis.me @dalias@hachyderm.io Which is kinda sad. I actually want trapping integers by default - both signed and unsigned. Wrapping behavior should be available as an attribute - again on both.

      Google - just like everyone else as it's all open source - has "some semblance of" trapping signed integers in some build configurations, but we can't have trapping unsigned integers because too much existing code depends on wrapping there (and the standard even mandates it). Like, yes, UBSan has an option for it, but have you ever tried running any real world code with it?

      And yet, with having trapping unsigned int, size_t actually becomes a good and safe to use type...

      Another fun problem of C++ is that some places use ssize_t (for example iterator differences, for obvious reasons). Thus, the larger range of size_t is not actually available anyway..;.

      In conversation about a day ago permalink
      Haelwenn /элвэн/ :triskell: likes this.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.