Hi Ted,
Ted Unangst wrote on Sat, Aug 26, 2017 at 02:35:01PM -0400:
> Ingo Schwarze wrote:
>> + if ((cp1 = mmap(NULL, sb1.st_size, PROT_READ, MAP_PRIVATE,
>> + fd1, 0)) == NULL) {
>> + say(MANDOC_DB, "&mmap");
>> + goto err;
>> + }
>> + if ((cp2 = mmap(NULL, sb2.st_size, PROT_READ, MAP_PRIVATE,
>> + fd2, 0)) == NULL) {
>> + say(tfn, "&mmap");
>> + goto err;
>> + }
> mmap returns MAP_FAILED (-1), not null, on failure.
Ooops, indeed. The check is correct in read.c and dbm_map.c,
but i stumbled here. Fixed now, thanks.
>> + for (i = 0; i < sb1.st_size; i++)
>> + if (cp1[i] != cp2[i])
>> + goto err;
> this could just be memcmp.
I avoided that over quibbles about the argument type (off_t vs.
size_t), though i admit that database files larger than a Gigabyte
make no sense at all.
If you consider that an improvement, i'm not opposed to using
memcmp(3). But i don't really have a good idea what to do if
st_size does happen to exceed SIZE_MAX. Maybe just error out?
Yours,
Ingo