Skip to content

Commit a91ab04

Browse files
committed
Security: fix vulnerability where -database parameter accepts arbitrary DSN strings
(cherry picked from commit 4dab3d5)
1 parent 1460aa1 commit a91ab04

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function build {
1818
GOOS=$3
1919
GOARCH=$4
2020

21-
if ! go version | egrep -q 'go(1\.1[56])' ; then
21+
if ! go version | egrep -q 'go1\.(1[5-9]|[2-9][0-9]{1})' ; then
2222
echo "go version must be 1.15 or above"
2323
exit 1
2424
fi

go/cmd/gh-ost/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package main
88
import (
99
"flag"
1010
"fmt"
11+
"net/url"
1112
"os"
1213
"os/signal"
1314
"syscall"
@@ -188,6 +189,11 @@ func main() {
188189
log.Fatalf("--database must be provided and database name must not be empty, or --alter must specify database name")
189190
}
190191
}
192+
193+
if err := flag.Set("database", url.QueryEscape(migrationContext.DatabaseName)); err != nil {
194+
migrationContext.Log.Fatale(err)
195+
}
196+
191197
if migrationContext.OriginalTableName == "" {
192198
if parser.HasExplicitTable() {
193199
migrationContext.OriginalTableName = parser.GetExplicitTable()

0 commit comments

Comments
 (0)