{"record":{"id":"7af0556fb76455ad","repo":"owasp-amass/amass","slug":"error-reading-the-first-512-bytes-from-s-s","errorCode":null,"errorMessage":"error reading the first 512 bytes from %s: %s","messagePattern":"error reading the first 512 bytes from (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/wordlist.go","lineNumber":125,"sourceCode":"}\n\nfunc getGzipReader(file *os.File, absPath string) (*gzip.Reader, error) {\n\tfinfo, err := file.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif finfo.Size() < 512 {\n\t\treturn nil, errors.New(\"file cannot be checked for compression\")\n\t}\n\n\t// We need to determine if this is a gzipped file or a plain text file, so we\n\t// first read the first 512 bytes to pass them down to http.DetectContentType\n\t// for mime detection. The file is rewinded before passing it along to the\n\t// next reader\n\thead := make([]byte, 512)\n\tif _, err = file.Read(head); err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading the first 512 bytes from %s: %s\", absPath, err)\n\t}\n\tif _, err = file.Seek(0, 0); err != nil {\n\t\treturn nil, fmt.Errorf(\"error rewinding the file %s: %s\", absPath, err)\n\t}\n\n\t// Read the file as gzip if it's actually compressed\n\tif mt := http.DetectContentType(head); mt == \"application/gzip\" || mt == \"application/x-gzip\" {\n\t\tgzReader, err := gzip.NewReader(file)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error gz-reading the file %s: %v\", absPath, err)\n\t\t}\n\n\t\treturn gzReader, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"%s is not compressed\", absPath)\n}\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/wordlist.go#L107-L143","documentation":"To decide whether the wordlist is gzipped, getGzipReader reads the first 512 bytes for content-type sniffing; this error is returned if that read fails. A successful os.Open followed by a failed Read usually indicates an I/O problem rather than a missing file.","triggerScenarios":"file.Read(head) errors inside getGzipReader (called from GetListFromFile): e.g. file is a special device, an I/O error occurs, or the fd is bad on exotic filesystems.","commonSituations":"Corrupt storage, reading from /proc-like pseudo files that error on read, or race conditions where the file was truncated/deleted mid-read.","solutions":["Re-run after confirming the file is a regular readable file (file <path>)","Replace a corrupted wordlist file","Check disk/filesystem health if errors persist"],"exampleFix":"// before\ncmd := exec.Command(tool, \"--wordlist\", \"/dev/random\")\n// after\ncmd := exec.Command(tool, \"--wordlist\", \"/usr/share/wordlists/common.txt\")","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err == nil && !info.Mode().IsRegular() { return errors.New(\"wordlist must be a regular file\") }","typeGuard":null,"tryCatchPattern":"words, err := GetListFromFile(p)\nif err != nil {\n  if strings.HasPrefix(err.Error(), \"error reading the first 512 bytes\") {\n    // verify file integrity / replace the wordlist\n  }\n  return err\n}","preventionTips":["Point wordlist settings at regular files, not devices or sockets","Verify wordlist checksums after download","Avoid exotic filesystems for wordlist storage"],"tags":["wordlist","gzip","io"],"backgroundTag":"file-read-failed","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}