Skip to content

br: ParseFrom func may overflow due to byte length overflow #63663

Closed

Description

@RidRisR
	for len(data) > 0 {
		switch data[0] {
		case flagShortValuePrefix:
			vlen := data[1]
			if len(data[2:]) < int(vlen) {
				return errors.Annotatef(berrors.ErrInvalidArgument,
					"the length of short value is invalid, vlen: %v", int(vlen))
			}
			v.shortValue = data[2 : vlen+2]
			data = data[vlen+2:]

vlen is a length flag, which only support 0-255. If vlen itself is 255, then vlen+2 would overflow.
We should transform it to a larger form to prevent the risk.

Activity

  1. added 3 commits that reference this issue on Sep 23, 2025
    b0cad21
    bf3d84b
    49bc537
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

    affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.component/brThis issue is related to BR of TiDB.severity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions