File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,13 +140,18 @@ bool apatch_uid_granted_root(uid_t uid) {
140140 }
141141
142142 for (size_t i = 0 ; i < config .size ; i ++ ) {
143- if (config .configs [i ].uid == uid ) {
144- _apatch_free_package_config (& config );
143+ if (config .configs [i ].uid != uid ) continue ;
145144
146- return config .configs [i ].root_granted ;
147- }
145+ /* INFO: This allow us to copy the information to avoid use-after-free */
146+ bool root_granted = config .configs [i ].root_granted ;
147+
148+ _apatch_free_package_config (& config );
149+
150+ return root_granted ;
148151 }
149152
153+ _apatch_free_package_config (& config );
154+
150155 return false;
151156}
152157
@@ -159,11 +164,14 @@ bool apatch_uid_should_umount(uid_t uid) {
159164 }
160165
161166 for (size_t i = 0 ; i < config .size ; i ++ ) {
162- if (config .configs [i ].uid == uid ) {
163- _apatch_free_package_config (& config );
167+ if (config .configs [i ].uid != uid ) continue ;
164168
165- return config .configs [i ].umount_needed ;
166- }
169+ /* INFO: This allow us to copy the information to avoid use-after-free */
170+ bool umount_needed = config .configs [i ].umount_needed ;
171+
172+ _apatch_free_package_config (& config );
173+
174+ return umount_needed ;
167175 }
168176
169177 _apatch_free_package_config (& config );
You can’t perform that action at this time.
0 commit comments