libs/lmo: apply FD_CLOEXEC on archive descriptors to avoid leaking i18n file fds...
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 24 Dec 2010 20:28:00 +0000 (20:28 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 24 Dec 2010 20:28:00 +0000 (20:28 +0000)
libs/lmo/src/lmo_core.c

index 6a9623a..0814138 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * lmo - Lua Machine Objects - Base functions
  *
 /*
  * lmo - Lua Machine Objects - Base functions
  *
- *   Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *   Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -94,6 +94,8 @@ lmo_archive_t * lmo_open(const char *file)
                ar->fd     = in;
                ar->length = idx_offset;
 
                ar->fd     = in;
                ar->length = idx_offset;
 
+               fcntl(ar->fd, F_SETFD, fcntl(ar->fd, F_GETFD) | FD_CLOEXEC);
+
                for( i = idx_offset;
                     i < (s.st_size - sizeof(uint32_t));
                     i += (4 * sizeof(uint32_t))
                for( i = idx_offset;
                     i < (s.st_size - sizeof(uint32_t));
                     i += (4 * sizeof(uint32_t))
@@ -230,4 +232,3 @@ int lmo_lookup(lmo_archive_t *ar, const char *key, char *dest, int len)
 
        return copy_len;
 }
 
        return copy_len;
 }
-