containers / composefs

a file system for mounting container images
GNU General Public License v2.0
421 stars 29 forks source link

writer: Set errno #263

Closed eriksjolund closed 5 months ago

eriksjolund commented 5 months ago

According to errno(3) a function that succeeds is allowed to change errno. What if memdup() succeeds?

I changed the code to match how it's written here https://github.com/containers/composefs/blob/d5ffbeb6844cdbe029f9c10cfa98239e2d6b1570/libcomposefs/lcfs-writer.c#L1472

eriksjolund commented 5 months ago

I added another small errno modification and rewrote the commit message.

cgwalters commented 5 months ago

At least systemd has a handy PRESERVE_ERRNO macro that I've used in other places too, and I think is a nicer approach. We could add that here.