Author: stsp
Date: Mon Aug 23 09:28:50 2021
New Revision: 1892541
URL: http://svn.apache.org/viewvc?rev=1892541&view=rev
Log:
Follow-up to r1892471:
Fix a regression where the resolver runs into a NULL-deref.
The wc_move_targets hash map is now always allocated and this exposed
missing NULL checks which resulted in attempts to search the hash map
with NULL keys. This was exposed by a segfault in the following test:
conflicts-test 45: cherry-pick edit from moved directory
* subversion/libsvn_client/conflicts.c
(resolve_incoming_move_file_text_merge,
resolve_local_move_dir_merge,
describe_incoming_move_merge_conflict_option,
svn_client_conflict_option_get_moved_to_abspath_candidates2,
svn_client_conflict_option_set_moved_to_abspath2): Ensure that we have
a valid hash key before searching the wc_move_targets hash map.
In all these cases this means that move_target_repos_relpath must
not be a NULL pointer.
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=1892541&r1=1892540&r2=1892541&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_client/conflicts.c Mon Aug 23 09:28:50
2021
@@ -8597,13 +8597,20 @@ resolve_incoming_move_file_text_merge(sv
* Merge from the local move's target location to the
* incoming move's target location. */
struct conflict_tree_local_missing_details *local_details;
- apr_array_header_t *moves;
local_details = conflict->tree_conflict_local_details;
- moves = svn_hash_gets(local_details->wc_move_targets,
- local_details->move_target_repos_relpath);
- merge_source_abspath =
- APR_ARRAY_IDX(moves, local_details->wc_move_target_idx, const char *);
+ if (local_details->wc_move_targets &&
+ local_details->move_target_repos_relpath)
+ {
+ apr_array_header_t *moves;
+ moves = svn_hash_gets(local_details->wc_move_targets,
+ local_details->move_target_repos_relpath);
+ merge_source_abspath =
+ APR_ARRAY_IDX(moves, local_details->wc_move_target_idx,
+ const char *);
+ }
+ else
+ merge_source_abspath = victim_abspath;
}
else
merge_source_abspath = victim_abspath;
@@ -9783,7 +9790,7 @@ resolve_local_move_dir_merge(svn_client_
NULL, conflict, scratch_pool,
scratch_pool));
- if (details->wc_move_targets)
+ if (details->wc_move_targets && details->move_target_repos_relpath)
{
apr_array_header_t *moves;
@@ -10732,7 +10739,8 @@ describe_incoming_move_merge_conflict_op
struct conflict_tree_incoming_delete_details *details;
details = conflict->tree_conflict_incoming_details;
- if (details->wc_move_targets)
+ if (details->wc_move_targets &&
+ details->move_target_repos_relpath)
{
apr_array_header_t *moves;
@@ -12265,7 +12273,7 @@ svn_client_conflict_option_get_moved_to_
*possible_moved_to_abspaths = apr_array_make(result_pool, 1,
sizeof (const char *));
- if (details->wc_move_targets)
+ if (details->wc_move_targets && details->move_target_repos_relpath)
{
apr_array_header_t *move_target_wc_abspaths;
move_target_wc_abspaths =
@@ -12459,7 +12467,7 @@ svn_client_conflict_option_set_moved_to_
svn_dirent_skip_ancestor(wcroot_abspath, preferred_sibling),
scratch_pool));
}
- else if (details->wc_move_targets)
+ else if (details->wc_move_targets && details->move_target_repos_relpath)
{
apr_array_header_t *move_target_wc_abspaths;
move_target_wc_abspaths =