Author: stsp
Date: Sun Aug 8 20:26:28 2021
New Revision: 1892118
URL: http://svn.apache.org/viewvc?rev=1892118&view=rev
Log:
Fix a NULL pointer dereference in the conflict resolver.
* subversion/libsvn_client/conflicts.c
(conflict_tree_get_details_local_missing): The find_related_node() helper
may return a NULL related_repo_relpath in some cases. Ensure that this
will not clobber the related_repo_relpath we already calculated and
bail out early in case we do end up with a NULL pointer.
Reported by: Joshua Kordani (jkordani {AT} roboticresearch dot com)
on users@ with a patch included in the report. Joshua kindly tested my
alternative fix for this issue and confirmed that it works as expected.
Modified:
subversion/trunk/subversion/libsvn_client/conflicts.c
Modified: subversion/trunk/subversion/libsvn_client/conflicts.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/conflicts.c?rev=1892118&r1=1892117&r2=1892118&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_client/conflicts.c Sun Aug 8 20:26:28
2021
@@ -2847,12 +2847,26 @@ conflict_tree_get_details_local_missing(
/* Make sure we're going to search the related node in a revision where
* it exists. The younger incoming node might have been deleted in HEAD. */
if (related_repos_relpath != NULL && related_peg_rev != SVN_INVALID_REVNUM)
- SVN_ERR(find_related_node(
- &related_repos_relpath, &related_peg_rev,
- related_repos_relpath, related_peg_rev,
- (old_rev < new_rev ? old_repos_relpath : new_repos_relpath),
- (old_rev < new_rev ? old_rev : new_rev),
- conflict, ctx, scratch_pool, scratch_pool));
+ {
+ const char *older_related_repos_relpath;
+ svn_revnum_t older_related_peg_rev;
+ SVN_ERR(find_related_node(
+ &older_related_repos_relpath, &older_related_peg_rev,
+ related_repos_relpath, related_peg_rev,
+ (old_rev < new_rev ? old_repos_relpath : new_repos_relpath),
+ (old_rev < new_rev ? old_rev : new_rev),
+ conflict, ctx, scratch_pool, scratch_pool));
+ if (older_related_repos_relpath != NULL &&
+ older_related_peg_rev != SVN_INVALID_REVNUM)
+ {
+ related_repos_relpath = older_related_repos_relpath;
+ related_peg_rev = older_related_peg_rev;
+ }
+ }
+
+ /* Bail if we are unable to find the related node. */
+ if (related_repos_relpath == NULL || related_peg_rev == SVN_INVALID_REVNUM)
+ return SVN_NO_ERROR;
/* Set END_REV to our best guess of the nearest YCA revision. */
url = svn_path_url_add_component2(repos_root_url, related_repos_relpath,