Download this file
| 1 | package hostfiles |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // ValidateManifest checks every entry and platform item of m against the |
| 6 | // admitted origins, as Restore and CopyManifest do before they touch |
| 7 | // anything (contracts note §1). A caller holding a manifest's exact bytes |
| 8 | // from somewhere other than its prefix (a relocation's retained copy) |
| 9 | // validates them with it before writing them under a new generation. |
| 10 | func ValidateManifest(m Manifest, origins []string) error { |
| 11 | if m.V != ManifestVersion { |
| 12 | return fmt.Errorf("hostfiles: manifest is version %d; this binary reads %d", m.V, ManifestVersion) |
| 13 | } |
| 14 | if len(origins) == 0 { |
| 15 | return ErrOrigin |
| 16 | } |
| 17 | for _, o := range origins { |
| 18 | if err := checkPrefix(o); err != nil { |
| 19 | return err |
| 20 | } |
| 21 | } |
| 22 | return checkManifest(m, origins) |
| 23 | } |
| 24 | |