node-maxmind
node-maxmind copied to clipboard
watchForUpdates doesn't validate file
Seems watchForUpdates doesn't check if the file is valid (for example if upload was broken). And crash with
mmdb-lib/lib/decoder.js:106
throw new Error('Unknown type ' + type + ' at offset ' + offset);
^
Error: Unknown type 87 at offset 1
at Decoder.decodeByType (/home/nodejs/node_modules/mmdb-lib/lib/decoder.js:106:15)
at Decoder.decode (/home/nodejs/node_modules/mmdb-lib/lib/decoder.js:58:21)
at parseMetadata (/home/nodejs/node_modules/mmdb-lib/lib/metadata.js:14:30)
at Reader.load (/home/nodejs/node_modules/mmdb-lib/lib/index.js:32:54)
at StatWatcher.<anonymous> (/home/nodejs/node_modules/maxmind/lib/index.js:56:20)
I suggest to check if mmdb file is valid and only then replace db in memory with new file.