mirror of https://github.com/minio/minio.git
Fix msgUnPath crash (#20614)
These are needed checks for the functions to be un-crashable with any input given to `msgUnPath` (tested with fuzzing). Both conditions would result in a crash, which prevents that. Some additional upstream checks are needed. Fixes #20610
This commit is contained in:
parent
7cb4b5c636
commit
8d42f37e4b
|
@ -37,6 +37,9 @@ func msgPath(s, prefix string) string {
|
|||
// dnsJoin joins labels to form a fully qualified domain name. If the last label is
|
||||
// the root label it is ignored. Not other syntax checks are performed.
|
||||
func dnsJoin(labels ...string) string {
|
||||
if len(labels) == 0 {
|
||||
return ""
|
||||
}
|
||||
ll := len(labels)
|
||||
if labels[ll-1] == "." {
|
||||
return strings.Join(labels[:ll-1], ".") + "."
|
||||
|
@ -50,6 +53,9 @@ func msgUnPath(s string) string {
|
|||
if l[len(l)-1] == "" {
|
||||
l = l[:len(l)-1]
|
||||
}
|
||||
if len(l) < 2 {
|
||||
return s
|
||||
}
|
||||
// start with 1, to strip /skydns
|
||||
for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 {
|
||||
l[i], l[j] = l[j], l[i]
|
||||
|
|
Loading…
Reference in New Issue