Comment 15 for bug 1933832

Revision history for this message
Seth Arnold (seth-arnold) wrote :

I think this will leak the fd in the event the error is hit:

         fd = os.open(path, os.O_NOFOLLOW | os.O_RDONLY | os.O_NONBLOCK)
         st = os.fstat(fd)
+ # make sure there are no symlinks in the full path
+ real_path = os.path.realpath(path)
+ if st.st_ino != os.stat(real_path).st_ino or path != real_path:
+ return 'Error: path contained symlinks.'

Thanks