Skip to content

Possibly hazardous check for static cmd argv validity #1943

Open

Description

@paddybyers

This check:

https://github.com/antirez/redis/blob/8237d88f48e0843839eb530c408686d66bcae6ab/src/scripting.c#L350

assumes that if argv has not changed then there has been no reallocation during the execution of the command.

However, if there is more than one call to rewriteClientCommandVector within the execution of a command (I don't know if this ever occurs in practice, but it seems hazardous to assume that) then it is possible for the argv to be freed and then reallocated at the same address but with a different length. This would potentially cause memory to be overwritten if it is reallocated at a smaller length than the original.

Perhaps the simplest fix is to have:

    if (c->argv != argv || c->argc != argv_size) {

Activity

  1. paddybyers commented on Aug 17, 2014

    @paddybyers
    ContributorAuthor

    Perhaps the simplest fix is to have:
    if (c->argv != argv || c->argc != argv_size) {

    Actually that's bad because it defeats the current behaviour of a static argv that grows as needed, without shrinking.

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