Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. bug of the day: a memcmp that only compares every fourth byte

bug of the day: a memcmp that only compares every fourth byte

Scheduled Pinned Locked Moved Uncategorized
25 Posts 10 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gsuberland@chaos.socialG gsuberland@chaos.social

    bug of the day: a memcmp that only compares every fourth byte

    dysfun@social.treehouse.systemsD This user is from outside of this forum
    dysfun@social.treehouse.systemsD This user is from outside of this forum
    dysfun@social.treehouse.systems
    wrote last edited by
    #2

    @gsuberland is it doing what i think it's doing?

    gsuberland@chaos.socialG 1 Reply Last reply
    0
    • dysfun@social.treehouse.systemsD dysfun@social.treehouse.systems

      @gsuberland is it doing what i think it's doing?

      gsuberland@chaos.socialG This user is from outside of this forum
      gsuberland@chaos.socialG This user is from outside of this forum
      gsuberland@chaos.social
      wrote last edited by
      #3

      @dysfun it's a constant time implementation if that helps

      gsuberland@chaos.socialG marzhall@app.wafrn.netM 2 Replies Last reply
      0
      • gsuberland@chaos.socialG gsuberland@chaos.social

        bug of the day: a memcmp that only compares every fourth byte

        petrillic@hachyderm.ioP This user is from outside of this forum
        petrillic@hachyderm.ioP This user is from outside of this forum
        petrillic@hachyderm.io
        wrote last edited by
        #4

        @gsuberland

        1 Reply Last reply
        0
        • gsuberland@chaos.socialG gsuberland@chaos.social

          @dysfun it's a constant time implementation if that helps

          gsuberland@chaos.socialG This user is from outside of this forum
          gsuberland@chaos.socialG This user is from outside of this forum
          gsuberland@chaos.social
          wrote last edited by
          #5

          @dysfun essentially this:

          int memcmp32(uint32_t* a, uint32_t* b, int words)
          {
          uint8_t sum = 0; // whoops
          while(words--) {
          sum |= *a++ ^ *b++;
          }
          return sum;
          }

          dysfun@social.treehouse.systemsD astraleureka@social.treehouse.systemsA 2 Replies Last reply
          0
          • gsuberland@chaos.socialG gsuberland@chaos.social

            bug of the day: a memcmp that only compares every fourth byte

            leo@60228.devL This user is from outside of this forum
            leo@60228.devL This user is from outside of this forum
            leo@60228.dev
            wrote last edited by
            #6

            @gsuberland@chaos.social what about an strncmp that doesn't stop at a null terminator

            leo@60228.devL 1 Reply Last reply
            0
            • gsuberland@chaos.socialG gsuberland@chaos.social

              @dysfun essentially this:

              int memcmp32(uint32_t* a, uint32_t* b, int words)
              {
              uint8_t sum = 0; // whoops
              while(words--) {
              sum |= *a++ ^ *b++;
              }
              return sum;
              }

              dysfun@social.treehouse.systemsD This user is from outside of this forum
              dysfun@social.treehouse.systemsD This user is from outside of this forum
              dysfun@social.treehouse.systems
              wrote last edited by
              #7

              @gsuberland yes, that's exactly what i thought

              gsuberland@chaos.socialG 1 Reply Last reply
              0
              • gsuberland@chaos.socialG gsuberland@chaos.social

                bug of the day: a memcmp that only compares every fourth byte

                rotopenguin@mastodon.socialR This user is from outside of this forum
                rotopenguin@mastodon.socialR This user is from outside of this forum
                rotopenguin@mastodon.social
                wrote last edited by
                #8

                @gsuberland my bad. I misheard directions, and used AL when what the boss really wanted was AI.

                1 Reply Last reply
                0
                • gsuberland@chaos.socialG gsuberland@chaos.social

                  @dysfun it's a constant time implementation if that helps

                  marzhall@app.wafrn.netM This user is from outside of this forum
                  marzhall@app.wafrn.netM This user is from outside of this forum
                  marzhall@app.wafrn.net
                  wrote last edited by
                  #9

                  @dysfun@social.treehouse.systems @gsuberland@chaos.social

                  Hmm… is the issue casting 64-bit memory to an 8-bit char?

                  gsuberland@chaos.socialG 1 Reply Last reply
                  0
                  • leo@60228.devL leo@60228.dev

                    @gsuberland@chaos.social what about an strncmp that doesn't stop at a null terminator

                    leo@60228.devL This user is from outside of this forum
                    leo@60228.devL This user is from outside of this forum
                    leo@60228.dev
                    wrote last edited by
                    #10

                    @gsuberland@chaos.social ....the famous wii trucha bug is probably because broadon didn't understand the difference between strncmp and memcmp, in their own libc they do the same thing

                    1 Reply Last reply
                    0
                    • gsuberland@chaos.socialG gsuberland@chaos.social

                      @dysfun essentially this:

                      int memcmp32(uint32_t* a, uint32_t* b, int words)
                      {
                      uint8_t sum = 0; // whoops
                      while(words--) {
                      sum |= *a++ ^ *b++;
                      }
                      return sum;
                      }

                      astraleureka@social.treehouse.systemsA This user is from outside of this forum
                      astraleureka@social.treehouse.systemsA This user is from outside of this forum
                      astraleureka@social.treehouse.systems
                      wrote last edited by
                      #11

                      @gsuberland @dysfun lmao

                      1 Reply Last reply
                      0
                      • gsuberland@chaos.socialG gsuberland@chaos.social

                        bug of the day: a memcmp that only compares every fourth byte

                        jannem@fosstodon.orgJ This user is from outside of this forum
                        jannem@fosstodon.orgJ This user is from outside of this forum
                        jannem@fosstodon.org
                        wrote last edited by
                        #12

                        @gsuberland
                        It's not named allmemcmp for a reason.

                        1 Reply Last reply
                        0
                        • dysfun@social.treehouse.systemsD dysfun@social.treehouse.systems

                          @gsuberland yes, that's exactly what i thought

                          gsuberland@chaos.socialG This user is from outside of this forum
                          gsuberland@chaos.socialG This user is from outside of this forum
                          gsuberland@chaos.social
                          wrote last edited by
                          #13

                          @dysfun ehehehe

                          the code in question lucked out by never actually using it in a path that matters, but it's in a core lib for something security sensitive so easily could've ended up being bad

                          dysfun@social.treehouse.systemsD 1 Reply Last reply
                          0
                          • gsuberland@chaos.socialG gsuberland@chaos.social

                            @dysfun ehehehe

                            the code in question lucked out by never actually using it in a path that matters, but it's in a core lib for something security sensitive so easily could've ended up being bad

                            dysfun@social.treehouse.systemsD This user is from outside of this forum
                            dysfun@social.treehouse.systemsD This user is from outside of this forum
                            dysfun@social.treehouse.systems
                            wrote last edited by
                            #14

                            @gsuberland yeah it lucked out by not having bit rotted yet

                            1 Reply Last reply
                            0
                            • marzhall@app.wafrn.netM marzhall@app.wafrn.net

                              @dysfun@social.treehouse.systems @gsuberland@chaos.social

                              Hmm… is the issue casting 64-bit memory to an 8-bit char?

                              gsuberland@chaos.socialG This user is from outside of this forum
                              gsuberland@chaos.socialG This user is from outside of this forum
                              gsuberland@chaos.social
                              wrote last edited by
                              #15

                              @marzhall @dysfun 32-bit, but yes

                              1 Reply Last reply
                              0
                              • gsuberland@chaos.socialG gsuberland@chaos.social

                                bug of the day: a memcmp that only compares every fourth byte

                                gsuberland@chaos.socialG This user is from outside of this forum
                                gsuberland@chaos.socialG This user is from outside of this forum
                                gsuberland@chaos.social
                                wrote last edited by
                                #16

                                i blogged about the memcmp thing

                                Watch out for missed warnings on vendor C++ toolchains - Graham Sutherland's Blog

                                favicon

                                (blog.poly.nomial.co.uk)

                                mildsunrise@tech.lgbtM reverseics@infosec.exchangeR 2 Replies Last reply
                                1
                                0
                                • gsuberland@chaos.socialG gsuberland@chaos.social

                                  i blogged about the memcmp thing

                                  Watch out for missed warnings on vendor C++ toolchains - Graham Sutherland's Blog

                                  favicon

                                  (blog.poly.nomial.co.uk)

                                  mildsunrise@tech.lgbtM This user is from outside of this forum
                                  mildsunrise@tech.lgbtM This user is from outside of this forum
                                  mildsunrise@tech.lgbt
                                  wrote last edited by
                                  #17

                                  @gsuberland unrelated but shouldn't it be something like *(a++) ^ *(b++)?

                                  gsuberland@chaos.socialG 1 Reply Last reply
                                  0
                                  • mildsunrise@tech.lgbtM mildsunrise@tech.lgbt

                                    @gsuberland unrelated but shouldn't it be something like *(a++) ^ *(b++)?

                                    gsuberland@chaos.socialG This user is from outside of this forum
                                    gsuberland@chaos.socialG This user is from outside of this forum
                                    gsuberland@chaos.social
                                    wrote last edited by
                                    #18

                                    @mildsunrise probably yeah I'm tired lol

                                    gsuberland@chaos.socialG 1 Reply Last reply
                                    0
                                    • gsuberland@chaos.socialG gsuberland@chaos.social

                                      @mildsunrise probably yeah I'm tired lol

                                      gsuberland@chaos.socialG This user is from outside of this forum
                                      gsuberland@chaos.socialG This user is from outside of this forum
                                      gsuberland@chaos.social
                                      wrote last edited by
                                      #19

                                      @mildsunrise wait no, cos (a++) would be equivalent to pre-increment

                                      gsuberland@chaos.socialG mildsunrise@tech.lgbtM 2 Replies Last reply
                                      0
                                      • gsuberland@chaos.socialG gsuberland@chaos.social

                                        @mildsunrise wait no, cos (a++) would be equivalent to pre-increment

                                        gsuberland@chaos.socialG This user is from outside of this forum
                                        gsuberland@chaos.socialG This user is from outside of this forum
                                        gsuberland@chaos.social
                                        wrote last edited by
                                        #20

                                        @mildsunrise but yeah it should be *a ^ *b and then separately incrementing

                                        1 Reply Last reply
                                        0
                                        • R relay@relay.infosec.exchange shared this topic
                                        • gsuberland@chaos.socialG gsuberland@chaos.social

                                          @mildsunrise wait no, cos (a++) would be equivalent to pre-increment

                                          mildsunrise@tech.lgbtM This user is from outside of this forum
                                          mildsunrise@tech.lgbtM This user is from outside of this forum
                                          mildsunrise@tech.lgbt
                                          wrote last edited by
                                          #21

                                          @gsuberland (a++) is post increment, pre increment would be (++a)

                                          gsuberland@chaos.socialG 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups