dbd/db2/statement.c

changeset 25
2cc3feba9277
parent 23
a4825c3e65e9
child 26
cf847efefdb5
--- a/dbd/db2/statement.c	Sat Dec 20 11:17:37 2008 +0000
+++ b/dbd/db2/statement.c	Sat Dec 20 23:53:07 2008 +0000
@@ -1,5 +1,7 @@
 #include "dbd_db2.h"
 
+#define BIND_BUFFER_SIZE    1024
+
 static lua_push_type_t db2_to_lua_push(unsigned int db2_type, int len) {
     lua_push_type_t lua_type;
 
@@ -80,7 +82,7 @@
     int errflag = 0;
     const char *errstr = NULL;
     SQLRETURN rc = SQL_SUCCESS;
-    unsigned char b[1024];
+    unsigned char b[BIND_BUFFER_SIZE];
     unsigned char *buffer = &b[0];
     int offset = 0;
     resultset_t *resultset = NULL; 
@@ -118,6 +120,10 @@
 	return 2;
     }
 
+    if (num_params > (BIND_BUFFER_SIZE/sizeof(double))) {
+        luaL_error(L, "Too many bind params: %d", num_params);
+    }
+
     for (p = 2; p <= n; p++) {
 	int i = p - 1;
 	int type = lua_type(L, p);

mercurial