File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -206,15 +206,20 @@ func (d *Device) createLinuxDevice() (err error) {
206
206
207
207
// scsiHostRescan: scans all scsi hosts.
208
208
func scsiHostRescan () error {
209
- scsiPath := "/sys/class/scsi_host/ "
209
+ scsiPath := "/sys/class/scsi_host"
210
210
dirs , err := os .ReadDir (scsiPath )
211
211
if err != nil {
212
212
return err
213
213
}
214
214
for _ , f := range dirs {
215
- name := filepath .Clean (scsiPath + f .Name () + "/scan" )
215
+ name := f .Name ()
216
+ // Reject any suspicious names
217
+ if strings .Contains (name , ".." ) || strings .ContainsAny (name , "/\\ " ) {
218
+ continue
219
+ }
220
+ path := filepath .Join (scsiPath , name , "scan" )
216
221
data := []byte ("- - -" )
217
- if err := os .WriteFile (name , data , 0666 ); err != nil {
222
+ if err := os .WriteFile (path , data , 0666 ); err != nil {
218
223
return fmt .Errorf ("scsi host rescan failed: %v" , err )
219
224
}
220
225
}
You can’t perform that action at this time.
0 commit comments