fix: validate ISO path is a file, not a directory; clear default value
This commit was merged in pull request #17.
This commit is contained in:
@@ -309,6 +309,19 @@ func handleDiskPartitions(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]any{"error": "missing iso parameter"})
|
||||
return
|
||||
}
|
||||
fi, err := os.Stat(iso)
|
||||
if err != nil {
|
||||
writeJSON(w, map[string]any{"error": fmt.Sprintf("cannot access %q: %v", iso, err)})
|
||||
return
|
||||
}
|
||||
if fi.IsDir() {
|
||||
writeJSON(w, map[string]any{"error": fmt.Sprintf("%q is a directory, not an ISO file", iso)})
|
||||
return
|
||||
}
|
||||
if !strings.HasSuffix(strings.ToLower(fi.Name()), ".iso") {
|
||||
writeJSON(w, map[string]any{"error": fmt.Sprintf("%q is not an ISO file", iso)})
|
||||
return
|
||||
}
|
||||
parts, err := listPartitions(iso)
|
||||
if err != nil {
|
||||
writeJSON(w, map[string]any{"error": err.Error()})
|
||||
|
||||
Reference in New Issue
Block a user