This fixes Bug#52410 reported by Vincent Vermilya.
* lib/backupfile.c (check_extension): Return a bool indicating
whether the original extension was OK. Caller changed.
(numbered_backup): Require that FILELEN does not count
trailing slashes after a non-slash, and don’t require
that *BUF be null-terminated. Caller changed.
This fixes a bug where the numbered backup file name for X/ was
incorrectly computed because the trailing slash messed up the code
looking for X.~1~, X.~2~, etc., and this caused numbered_backup
to loop forever. Also, check that check_extension doesn’t
truncate a file name leading to a different infloop.