From: Derrick Stolee Date: Mon, 17 Jun 2019 01:17:24 GMT Subject: Re: [PATCH] fsmonitor: avoid signed integer overflow / infinite loop Message-ID: <0915f2bc-5818-3bf5-34c2-7c783363cc34@gmail.com> In-Reply-To: <20190615161135.57269-1-carenas@gmail.com> On 6/15/2019 12:11 PM, Carlo Marcelo Arenas Belón wrote: > 883e248b8a ("fsmonitor: teach git to optionally utilize a file system > monitor to speed up detecting new or changed files.", 2017-09-22) uses > an int in a loop that would wrap if index_state->cache_nr (unsigned) > is bigger than INT_MAX Thanks for catching this. I wonder if there is a compiler setting or static analysis that caught this so we can avoid the issue in the future. Also, INT_MAX is ~2.1 billion, and the largest indexes I know about have around 4 million entries, so it is unlikely that you hit this as a runtime error. Still worth fixing! Thanks, -Stolee