Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-42147

cbflag help message possible negative repeat count using 'string.Repeat'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.0.0
    • Cheshire-Cat
    • tools
    • None
    • Untriaged
    • 1
    • No

    Description

      What's the issue?
      It looks like cbflag doesn't correctly handle abnormally large help strings correctly. When calculating the post message padding we're causing a panic because we're supplying a negative repeat count to 'strings.Repeat'.

      james@ponos ~/Projects/couchbase-build/backup cbbackupmgr config -a ~/Projects/couchbase-archive -r repo -h
      panic: strings: negative Repeat count
       
      goroutine 1 [running]:
      strings.Repeat(0xfc95c8, 0x1, 0xfffffffffffffffe, 0xc00030f958, 0x2)
              /usr/lib/go/src/strings/strings.go:529 +0x5e5
      github.com/couchbase/cbflag.(*Flag).usageString(0xc0003d9200, 0xc0003f6400, 0x3f9)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/flag.go:210 +0x4ba
      github.com/couchbase/cbflag.(*Command).Usage(0xc00031e700, 0xc00021f470, 0xc000310820)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/command.go:324 +0x365
      github.com/couchbase/cbflag.(*Command).parseFlags(0xc00031e700, 0xc00021f470, 0xc000032090, 0x5, 0x5)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/command.go:208 +0x19d0
      github.com/couchbase/cbflag.(*Command).parse(0xc00031e700, 0xc00021f470, 0xc000032090, 0x5, 0x5)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/command.go:92 +0x151
      github.com/couchbase/cbflag.(*Command).parseCommands(0xc00031f0a0, 0xc00021f470, 0xc000032080, 0x6, 0x6)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/command.go:104 +0x135
      github.com/couchbase/cbflag.(*Command).parse(0xc00031f0a0, 0xc00021f470, 0xc000032080, 0x6, 0x6)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/command.go:90 +0xd1
      github.com/couchbase/cbflag.(*CLI).Parse(0xc0003d4090, 0xc000032070, 0x7, 0x7)
              /home/james/.local/lib/golang/pkg/mod/github.com/couchbase/cbflag@v0.0.0-20200914082931-961919bbb973/cli.go:59 +0x193
      main.main()
              /home/james/Projects/couchbase-build/backup/cmd/cbbackupmgr/main.go:3124 +0x10145
      
      

      Attachments

        Issue Links

          For Gerrit Dashboard: MB-42147
          # Subject Branch Project Status CR V

          Activity

            People

              james.lee James Lee
              james.lee James Lee
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty