@@ -966,11 +966,8 @@ static void map_link(link_ctx *ctx)
966966 apr_cpystrn (buffer , ctx -> p_server_uri , sizeof (buffer ));
967967 buffer_len = ctx -> psu_len ;
968968 }
969- if (need_len > sizeof (buffer )) {
970- ap_log_rerror (APLOG_MARK , APLOG_WARNING , 0 , ctx -> r , APLOGNO (03482 )
971- "link_reverse_map uri too long, skipped: %s" , ctx -> s );
972- return ;
973- }
969+ if (need_len > sizeof (buffer ))
970+ goto out ;
974971 apr_cpystrn (buffer + buffer_len , ctx -> s + ctx -> link_start , link_len + 1 );
975972 if (!prepend_p_server
976973 && strcmp (ctx -> real_backend_uri , ctx -> p_server_uri )
@@ -979,6 +976,9 @@ static void map_link(link_ctx *ctx)
979976 * to work, we need to use the proxy uri */
980977 int path_start = ctx -> link_start + ctx -> rbu_len ;
981978 link_len -= ctx -> rbu_len ;
979+ need_len = ctx -> psu_len + link_len ;
980+ if (need_len > sizeof (buffer ))
981+ goto out ;
982982 memcpy (buffer , ctx -> p_server_uri , ctx -> psu_len );
983983 memcpy (buffer + ctx -> psu_len , ctx -> s + path_start , link_len );
984984 buffer_len = ctx -> psu_len + link_len ;
@@ -999,6 +999,11 @@ static void map_link(link_ctx *ctx)
999999 }
10001000 subst_str (ctx , ctx -> link_start , ctx -> link_end , mapped );
10011001 }
1002+ out :
1003+ if (need_len > sizeof (buffer )) {
1004+ ap_log_rerror (APLOG_MARK , APLOG_WARNING , 0 , ctx -> r , APLOGNO (03482 )
1005+ "link_reverse_map uri too long, skipped: %s" , ctx -> s );
1006+ }
10021007 }
10031008}
10041009
0 commit comments