Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior when specifying same input and output file #21

Open
marcobellaccini opened this issue Sep 30, 2018 · 6 comments
Open

Comments

@marcobellaccini
Copy link

Hi!
Yesterday a programmer pointed out a corner case in pyAesCrypt usage:
marcobellaccini/pyAesCrypt#5
He was wondering whether specifying same input and output file is legit.
I don't think that's a valid use case, so I explicitly prevented the user from doing it.
For the sake of completeness, I've tested the same use case with the Linux command-line version of AESCrypt (v3.13) and I've got this error:

$ aescrypt -o foo.aes -d foo.aes
Enter password: ******
Error: Input file is too short.

after executing the command, foo.aes is deleted too.

Cheers

Marco

@marcobellaccini marcobellaccini changed the title Unexpected beavior when specifying same input and output file Unexpected behavior when specifying same input and output file Sep 30, 2018
@paulej
Copy link
Owner

paulej commented Sep 30, 2018

While that's true, I don't want to make an effort to prevent it. It might be possible to prevent some instances, it's possible that the same file has different names for to using symbolic links, hard links, etc.

@marcobellaccini
Copy link
Author

Hi Paul!
Ok, I understand your point. It has been easy for me to avoid troubles with links using a nice Python standard library function, but, of course, in C everything is harder.

Cheers

Marco

@paulej
Copy link
Owner

paulej commented Sep 30, 2018

I'll bet a normal link on Linux would fool even the python code. One option that might work is to lock the input file exclusively. But that's got other negative consequences, like background backup processes failing.

@marcobellaccini
Copy link
Author

No, it works (I've tested it).
As reported in the "samefile" function documentation, it checks the i-node number.

@paulej
Copy link
Owner

paulej commented Oct 1, 2018

Very nice. I didn't expect it to be that thorough.

@marcobellaccini
Copy link
Author

Yeah, in fact I think the implementation is pretty complex...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants