File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1018,6 +1018,8 @@ static int is_allowed_usb_path(const char *path) {
10181018 int payload_mgr_delete_payload_file (const char * filename ) {
10191019 char path [512 ];
10201020 char details_path [640 ];
1021+ char dir_path [512 ];
1022+ char * last_slash ;
10211023
10221024 if (!filename || strstr (filename , "/" ) || strstr (filename , ".." )) {
10231025 return -1 ;
@@ -1037,6 +1039,15 @@ static int is_allowed_usb_path(const char *path) {
10371039 /* Remove from autoload.txt if present */
10381040 pldmgr_autoload_update_config_entry (filename , NULL );
10391041
1042+ /* Try to remove the containing directory (will fail if not empty) */
1043+ strncpy (dir_path , path , sizeof (dir_path ));
1044+ dir_path [sizeof (dir_path ) - 1 ] = '\0' ;
1045+ last_slash = strrchr (dir_path , '/' );
1046+ if (last_slash ) {
1047+ * last_slash = '\0' ;
1048+ rmdir (dir_path );
1049+ }
1050+
10401051 return 0 ;
10411052 }
10421053
You can’t perform that action at this time.
0 commit comments