Hacker News new | past | comments | ask | show | jobs | submit login

It's neither a feature nor a hack, it's simply a bug related to missing the O_TRUNC flag when opening the file for modification. No deliberate attempt was made to "hold onto" any data.



I feel like we’re talking past each other. I’ll find my answers elsewhere. Thanks for your time!


My (limited) understanding is that if you have say a 5mb file, and you open it for writing and wrote 3mb. You might expect the file to be 3mb, but...if you didn't specify the truncate flag (the bug here) the file is still actually the 5mb it was. The image appears cropped because the relevant metadata has the new sizes etc, but that 2mb of extra data is still there by mistake. This can be used to recover some of the original image.


Aha! Thanks.

So this behaviour is likely unfit to be used as a feature, but could in some cases be used as a clever hack to, in a way, preserve some edited (cropped) data.


No, it is not suitable as a clever hack. It doesn't work reliably or well enough for that.


With all due respect, it's simply that you haven't properly understood the article.

You sound like you're probably fairly smart but I suspect you're rushing this one and commenting before you've properly grasped the topic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: