Skip to content

Rope code appears to do a string overrun #2236

Closed

Description

@graydon

In commit 956bc77 I had to disable one of the rope tests. The purpose of that commit was to fix up a bug in the way operator [] works on strings. In particular it used to let you index up to and including the trailing null; now it considers access to the null byte an index overrun and fails.

I tried to figure out exactly what was going on in the rope code for quite a while, and tried adjusting a number of obvious-looking things, but to no avail. I'm not really good with boundary-case arithmetic (are any of us?) and the rope module is a maze of such arithmetic.

Sharper minds requested to find the bug. Meanwhile I marked the rope test in question (char_at1) as ignored. The others seem to work.

Activity

  1. catamorphism commented on Apr 19, 2012

    @catamorphism
    Contributor

    Paging @Yoric

  2. Yoric commented on Apr 22, 2012

    @Yoric
    Contributor

    I'll take a look.

  3. msullivan commented on Jul 2, 2013

    @msullivan
    Contributor

    There is some discussion on IRC that maybe we should just pitch the rope code as it exists now.

  4. Aatch commented on Jul 3, 2013

    @Aatch
    Contributor

    @msullivan agreed. The code is pretty outdated and the work required to modernize it would probably be similar to the work needed to just re-write it.

    When I was looking through it, it seemed to be doing some very strange things that I don't think are even close to being safe, so there's that too.

  5. added a commit that references this issue on Sep 22, 2022
  6. added a commit that references this issue on Feb 11, 2025
  7. added a commit that references this issue on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions