zongganli@tencent.com


Found
r1919535

r1919535 | dsahlberg | 2024-07-26 16:33:52 +0000 (Fri, 26 Jul 2024)

Fix the check for limit < 0 in svnlook.

strtol will parse a signed long and thus for example accept -1. But the limit
field in opt_state is apr_size_t which can be an unsigned type. If this is the
case, the later check for opt_state.limit <= 0 will not see -1 but rather
INT_MAX (or LONG_MAX or whatever) and thus the error message "Argument to 
--limit must be positive" is never shown.

Changing the check to be the same as in subversion/svn/svn.c. This has a few
implications:
- The limit in svn.c is int. If apr_size_t was larger this means a lower
  maximum for --limit is now enforced.
- svnlook and svn now behave the same with regards to the limit option.

* subversion/svnlook/svnlook.c:
  (struct svnlook_opt_state),
  (struct svnlook_ctxt_t),
  (struct print_history_baton): change limit from apr_size to int
  (sub_main): Change handling of opt_id == 'l' to the same as in svn.c

See dev@: https://lists.apache.org/thread/kg36nodcgtgkcfww8qy88kyl7h46ry7x

Found by: zongganli@tencent.com