Replace int for Maximum/MinimumFileCount with uint, since there should never be negative values and default value overflows otherwise

This commit is contained in:
Seednode 2023-09-15 13:53:12 -05:00
parent 0d252d0456
commit f5eb1f56f4
2 changed files with 6 additions and 6 deletions

View File

@ -332,7 +332,7 @@ func scanPath(path string, fileChannel chan<- string, statChannel chan<- *scanSt
errorChannel <- err errorChannel <- err
} }
if files > 0 && (files < MinimumFileCount) || (files > MaximumFileCount) { if files > 0 && (files < int(MinimumFileCount)) || (files > int(MaximumFileCount)) {
// This count will not otherwise include the parent directory itself, so increment by one // This count will not otherwise include the parent directory itself, so increment by one
stats.directoriesSkipped = stats.directoriesSkipped + directories + 1 stats.directoriesSkipped = stats.directoriesSkipped + directories + 1
stats.filesSkipped = stats.filesSkipped + files stats.filesSkipped = stats.filesSkipped + files

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
ReleaseVersion string = "0.88.0" ReleaseVersion string = "0.88.1"
) )
var ( var (
@ -27,8 +27,8 @@ var (
Handlers bool Handlers bool
Images bool Images bool
Info bool Info bool
MaximumFileCount int MaximumFileCount uint
MinimumFileCount int MinimumFileCount uint
PageLength uint32 PageLength uint32
Port uint16 Port uint16
Prefix string Prefix string
@ -77,8 +77,8 @@ func init() {
rootCmd.Flags().BoolVar(&Handlers, "handlers", false, "display registered handlers (for debugging)") rootCmd.Flags().BoolVar(&Handlers, "handlers", false, "display registered handlers (for debugging)")
rootCmd.Flags().BoolVar(&Images, "images", false, "enable support for image files") rootCmd.Flags().BoolVar(&Images, "images", false, "enable support for image files")
rootCmd.Flags().BoolVarP(&Info, "info", "i", false, "expose informational endpoints") rootCmd.Flags().BoolVarP(&Info, "info", "i", false, "expose informational endpoints")
rootCmd.Flags().IntVar(&MaximumFileCount, "maximum-files", 1<<32-1, "skip directories with file counts above this value") rootCmd.Flags().UintVar(&MaximumFileCount, "maximum-files", 1<<32-1, "skip directories with file counts above this value")
rootCmd.Flags().IntVar(&MinimumFileCount, "minimum-files", 1, "skip directories with file counts below this value") rootCmd.Flags().UintVar(&MinimumFileCount, "minimum-files", 1, "skip directories with file counts below this value")
rootCmd.Flags().Uint32Var(&PageLength, "page-length", 0, "pagination length for info pages") rootCmd.Flags().Uint32Var(&PageLength, "page-length", 0, "pagination length for info pages")
rootCmd.Flags().Uint16VarP(&Port, "port", "p", 8080, "port to listen on") rootCmd.Flags().Uint16VarP(&Port, "port", "p", 8080, "port to listen on")
rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)") rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)")