mirror of
https://github.com/distribution/distribution.git
synced 2026-05-01 12:55:30 +00:00
PurgeUploads' Walk callback split the visited path with path.Split and indexed file[0] immediately. path.Split returns an empty basename for paths that end in a trailing slash - in practice this happens when an S3 driver surfaces a bare directory (common prefix) with an empty Key. Indexing a zero-length string then panics with 'index out of range [0] with length 0' and takes down the whole PurgeUploads goroutine (#4713). Guard the length before touching file[0] so a trailing-slash / empty-basename entry is simply skipped as 'not a reserved directory', which matches what the branch was trying to do anyway. Runtime behaviour for every non-empty entry is unchanged. Closes #4713 Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>