-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
path.dirname used in loop #7461
Description
I recently ran into an issue where there was a routine that creates a directory as well as all missing parent directories. It calls path.dirname() to get its parent directory and, if it doesn't exist, recurses into itself. Eventually it gets to some directory that exists and then works its way back, making the new subordinate directories.
In my case, I was providing a UNC (which is an expected use-case) and didn't have access to the share. So, the existence check was failing and it kept trying to move to the parent directory. Unfortunately, path.dirname()'s default functionality is to essentially return "\host\share" if given "\host\share" (because this is considered the "drive" and the highest-most root element). It won't peel away any further layers. This caused an infinite loop.
Can we modify path.dirname() to assert that what gets returned is not equaled to the argument?