Skip to content

Commit

Permalink
Security: fix vulnerability where -database parameter accepts arbit…
Browse files Browse the repository at this point in the history
…rary DSN strings

(cherry picked from commit 4dab3d5)
  • Loading branch information
dm-2 committed Jan 18, 2022
1 parent 1460aa1 commit a91ab04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function build {
GOOS=$3
GOARCH=$4

if ! go version | egrep -q 'go(1\.1[56])' ; then
if ! go version | egrep -q 'go1\.(1[5-9]|[2-9][0-9]{1})' ; then
echo "go version must be 1.15 or above"
exit 1
fi
Expand Down
6 changes: 6 additions & 0 deletions go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package main
import (
"flag"
"fmt"
"net/url"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -188,6 +189,11 @@ func main() {
log.Fatalf("--database must be provided and database name must not be empty, or --alter must specify database name")
}
}

if err := flag.Set("database", url.QueryEscape(migrationContext.DatabaseName)); err != nil {
migrationContext.Log.Fatale(err)
}

if migrationContext.OriginalTableName == "" {
if parser.HasExplicitTable() {
migrationContext.OriginalTableName = parser.GetExplicitTable()
Expand Down

0 comments on commit a91ab04

Please # to comment.