@@ -244,20 +244,11 @@ void sbox_map_path_at(
244244{
245245 const char * dirfd_path ;
246246
247- if (!virtual_path ) {
248- res -> mres_result_buf = res -> mres_result_path = NULL ;
249- res -> mres_readonly = 1 ;
250- return ;
251- }
252- if (* virtual_path == '\0' ) {
253- goto end ;
254- }
255-
256- if ((* virtual_path == '/' )
247+ if (virtual_path && ((* virtual_path == '/' )
257248#ifdef AT_FDCWD
258249 || (dirfd == AT_FDCWD )
259250#endif
260- ) {
251+ )) {
261252 /* same as sbox_map_path() */
262253 fwd_map_path (
263254 (sbox_binary_name ? sbox_binary_name : "UNKNOWN" ),
@@ -273,10 +264,17 @@ void sbox_map_path_at(
273264 /* pathname found */
274265 char * virtual_abs_path_at_fd = NULL ;
275266
276- if (asprintf (& virtual_abs_path_at_fd , "%s/%s" , dirfd_path , virtual_path ) < 0 ) {
277- /* asprintf failed */
278- abort ();
279- }
267+ if (!virtual_path ) {
268+ if (asprintf (& virtual_abs_path_at_fd , "%s" , dirfd_path ) < 0 ) {
269+ /* asprintf failed */
270+ abort ();
271+ }
272+ } else {
273+ if (asprintf (& virtual_abs_path_at_fd , "%s/%s" , dirfd_path , virtual_path ) < 0 ) {
274+ /* asprintf failed */
275+ abort ();
276+ }
277+ }
280278 SB_LOG (SB_LOGLEVEL_DEBUG ,
281279 "Synthetic path for %s(%d,'%s') => '%s'" ,
282280 func_name , dirfd , virtual_path , virtual_abs_path_at_fd );
@@ -289,15 +287,6 @@ void sbox_map_path_at(
289287
290288 return ;
291289 }
292-
293- end :
294- /* name not found. Can't do much here, log a warning and return
295- * the original relative path. That will work if we are lucky, but
296- * not always.. */
297- SB_LOG (SB_LOGLEVEL_WARNING , "Path not found for FD %d, for %s(%s)" ,
298- dirfd , func_name , virtual_path );
299- res -> mres_result_buf = res -> mres_result_path = strdup (virtual_path );
300- res -> mres_readonly = 0 ;
301290}
302291
303292/* this maps the path and then leaves "rule" and "exec_policy" to the stack,
0 commit comments