On Sat, 31 Jul 2010, Ted Unangst wrote:

> luazlib is not 64-bit safe.  look at line 123 of the source.  it's passing 
> the address of an int to a function expecting a size_t.  if size_t is 
> bigger than in, poop.
> 
> I'd fix it, but I can't get the port to build right now.  This is almost 
> certainly my own fault, but I thought I'd at least point at that the code 
> is wrong by inspection.

Here's the patch I sent to the author.

--- lua_zlib.c.orig     Sat Jul 31 10:13:28 2010
+++ lua_zlib.c  Sat Jul 31 10:14:21 2010
@@ -84,6 +84,7 @@
      int flush = Z_NO_FLUSH, result;
      z_stream* stream;
      luaL_Buffer buff;
+     size_t avail_in;
 
     if ( filter == deflate ) {
         const char *const opts[] = { "none", "sync", "full", "finish", NULL };
@@ -120,7 +121,8 @@
     }
 
     /*  Do the actual deflate'ing: */
-    stream->next_in = (unsigned char*)lua_tolstring(L, -1, 
(size_t*)&(stream->avail_in));
+    stream->next_in = (unsigned char*)lua_tolstring(L, -1, &avail_in);
+    stream->avail_in = avail_in;
     if ( ! stream->avail_in && ! flush ) {
         /*  Passed empty string, make it a noop instead of erroring out. */
         lua_pushstring(L, "");

Reply via email to