Convert Split() calls with an equal sign to SplitN()

After seeing #7759, I decided to look at the calls in
Podman and Buildah to see if we had issues with strings.Split()
calls where an "=" (equals) sign was in play and we expected
to split on only the first one.

There were only one or two that I found in here that I think
might have been troubling, the remainder are just adding
some extra safety.

I also had another half dozen or so that were checking length
expectations appropriately, those I left alone.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
This commit is contained in:
TomSweeneyRedHat
2020-09-24 19:33:34 -04:00
parent d1ba9ce555
commit 33366a2cda
7 changed files with 17 additions and 15 deletions

View File

@ -474,8 +474,8 @@ func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
config.Storage.RunRoot = storeOptions.RunRoot
config.Storage.GraphRoot = storeOptions.GraphRoot
for _, i := range storeOptions.GraphDriverOptions {
s := strings.Split(i, "=")
if s[0] == "overlay.mount_program" {
s := strings.SplitN(i, "=", 2)
if s[0] == "overlay.mount_program" && len(s) == 2 {
config.Storage.Options.MountProgram = s[1]
}
}