]> git.ozlabs.org Git - ccan/blobdiff - ccan/grab_file/grab_file.c
container_of: don't put member_ptr in container_off.
[ccan] / ccan / grab_file / grab_file.c
index b3a2f54d512ea07f5c10b9e95c5cafbb59bd0771..2a9d0cd7632c5d5739fb3b5581ec2780db00f8ce 100644 (file)
@@ -1,3 +1,4 @@
+/* Licensed under LGPLv2+ - see LICENSE file for details */
 #include "grab_file.h"
 #include <ccan/talloc/talloc.h>
 #include <ccan/noerr/noerr.h>
@@ -17,7 +18,7 @@ void *grab_fd(const void *ctx, int fd, size_t *size)
                size = &s;
        *size = 0;
 
-       if (fstat(fd, &st) == 0)
+       if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode))
                max = st.st_size;
        else
                max = 16384;