Fix for issue 816 * subversion/libsvn_client/log.c (svn_client_log): Tests added to ensure version numbers passed to it are between 0 and head inclusive Throws SVN_ERR_CLIENT_BAD_REVISION if new tests fail. * subversion/include/svn_client.h (svn_client_log comment text): amended to mention the new revision number tests. Index: subversion/libsvn_client/log.c =================================================================== --- subversion/libsvn_client/log.c +++ subversion/libsvn_client/log.c Sat Jul 27 18:52:04 2002 @@ -62,9 +62,11 @@ const char *URL; const char *base_name = NULL; apr_array_header_t *condensed_targets; - svn_revnum_t start_revnum, end_revnum; + svn_revnum_t start_revnum, end_revnum, head_revnum; svn_error_t *err; + svn_client_revision_t head; + head.kind = svn_client_revision_head; if ((start->kind == svn_client_revision_unspecified) || (end->kind == svn_client_revision_unspecified)) { @@ -73,7 +75,7 @@ "svn_client_log: caller failed to supply revision"); } - start_revnum = end_revnum = SVN_INVALID_REVNUM; + start_revnum = end_revnum = head_revnum = SVN_INVALID_REVNUM; path = (APR_ARRAY_IDX(targets, 0, const char *)); @@ -151,6 +153,51 @@ (&start_revnum, ra_lib, session, start, base_name, pool)); SVN_ERR (svn_client__get_revision_number (&end_revnum, ra_lib, session, end, base_name, pool)); + SVN_ERR (svn_client__get_revision_number + (&head_revnum, ra_lib, session, &head, base_name, pool)); + + /* Here, we check that the versions input were valid. If not, we + return an error */ + if (start_revnum > head_revnum && end_revnum > head_revnum) + { + err = svn_error_createf(SVN_ERR_CLIENT_BAD_REVISION, 0, NULL, pool, + "Both revision numbers too high: %" + SVN_REVNUM_T_FMT " and %" SVN_REVNUM_T_FMT + ". Head is %" SVN_REVNUM_T_FMT ".", + start_revnum, end_revnum, head_revnum); + return err; + } + + if (start_revnum > head_revnum || end_revnum > head_revnum) + { + err = svn_error_createf(SVN_ERR_CLIENT_BAD_REVISION, 0, NULL, pool, + "Revision number too high: %" SVN_REVNUM_T_FMT + ". Head is %" SVN_REVNUM_T_FMT ".", + (start_revnum > end_revnum)? \ + start_revnum:end_revnum, + head_revnum); + return err; + } + + if (start_revnum < 0 && end_revnum < 0) + { + err = svn_error_createf(SVN_ERR_CLIENT_BAD_REVISION, 0, NULL, pool, + "Both revision numbers are negative: %" + SVN_REVNUM_T_FMT " and %" SVN_REVNUM_T_FMT + ". Negative revision number are not allowed.", + start_revnum, end_revnum); + return err; + } + + if (start_revnum < 0 || end_revnum < 0) + { + err = svn_error_createf(SVN_ERR_CLIENT_BAD_REVISION, 0, NULL, pool, + "Revision number negative: %" SVN_REVNUM_T_FMT + ". Negative revision numbers are not allowed.", + (start_revnum < end_revnum)? \ + start_revnum:end_revnum); + return err; + } err = ra_lib->get_log (session, condensed_targets, Index: subversion/include/svn_client.h =================================================================== --- subversion/include/svn_client.h +++ subversion/include/svn_client.h Sat Jul 27 17:11:41 2002 @@ -556,6 +556,13 @@ If START->kind or END->kind is svn_client_revision_unspecified, return the error SVN_ERR_CLIENT_BAD_REVISION. + If the version number returned after canonicalising either START or + FINISH is greater than that of head, return the error + SVN_ERR_CLIENT_BAD_REVISION + + If the version number returned after canonicalising either START or + FINISH is negative, return the error SVN_ERR_CLIENT_BAD_REVISION + Use POOL for any temporary allocation. Special case for repositories at revision 0: