Richard Hipp escribió:
On Tue, Apr 26, 2011 at 3:18 PM, Neven Boric<nbo...@yx.cl>  wrote:

Hi

I'm using Freeswitch, which has an old version of SQLite embedded in its
source code. I'm getting a segmentation fault whenever I do something that
uses triggers. The segmentation fault occurs inside SQLite code (strdup gets
called with a null pointer inside sqlite3ExprListDup). Freeswicth uses
SQLite extensively without problems, but I have found no other uses of
triggers in the code, so this problem might have gone unnoticed so far.

The version that Freeswitch uses is very old (3.3.13),  so I wouldn't
expect anyone to look into this problem, as if it is indeed a bug in SQLite,
it is likely alredy fixed in a more recent version. The problem is I don't
know how much trouble I would find trying to update the SQLite version
included with Freeswitch. So what I wanted to ask is: by looking at the
backtrace, does it seem like a SQLite bug that should be fixed in a more
recent version?


SQLite no longer uses strdup().  So this particular bug is very likely
fixed.

I finally found the 3.3.13 code in fossil. I compared it to the Freeswicth source and there are several "minor" changes. Attached is a patch file with the most relevant change. You can see they replaced calls to sqliteStrDup with calls to strdup. Problem is sqliteStrDup checks for NULL input, whereas strdup does not. So, I believe this is a Freeswitch introduced bug. Right now I'm compiling to see if reverting this fixes the issue.



Thanks in advance.

Neven Boric

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users




--- 
/home/nvn/code/fs_x86/repos/fs_x86/freeswitch.git/libs/sqlite/src/sqliteInt.h   
    2011-04-27 08:25:34.495690822 -0300
+++ /home/nvn/Desktop/SQLite-286c4eb30dfe1e8e/src/sqliteInt.h   2007-02-13 
10:04:54.000000000 -0300
@@ -61,9 +61,6 @@
 #include "hash.h"
 #include "parse.h"
 #include <stdio.h>
-#ifdef __OpenBSD__
-#include <stdint.h>
-#endif
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
@@ -272,38 +269,17 @@
 
 #else
 
-#ifdef _MSC_VER
-#define inline __inline
-#endif
-
-static inline void *zmalloc(size_t x)
-{
-       void *z = malloc(x);
-       assert(z);
-       memset(z, 0, x);
-       return z;
-}
-
-static inline char *strndup_lite(const char *s, size_t n)
-{
-       char *dup = malloc(n+1);
-       assert(dup);
-       memcpy(dup, s, n);
-       *(dup+n) = '\0';
-       return dup;
-}
-
 #define ENTER_MALLOC 0
-#define sqliteMalloc(x)          zmalloc(x)//sqlite3Malloc(x,1)
-#define sqliteMallocRaw(x)       malloc(x)//sqlite3MallocRaw(x,1)
-#define sqliteRealloc(x,y)       realloc(x, y)//sqlite3Realloc(x,y)
-#define sqliteStrDup(x)          strdup(x)//sqlite3StrDup(x)
-#define sqliteStrNDup(x,y)       strndup_lite(x,y) //sqlite3StrNDup(x,y)
+#define sqliteMalloc(x)          sqlite3Malloc(x,1)
+#define sqliteMallocRaw(x)       sqlite3MallocRaw(x,1)
+#define sqliteRealloc(x,y)       sqlite3Realloc(x,y)
+#define sqliteStrDup(x)          sqlite3StrDup(x)
+#define sqliteStrNDup(x,y)       sqlite3StrNDup(x,y)
 #define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y)
 
 #endif
 
-#define sqliteFree(x)          if (x) { free((void *)x); x = NULL;} 
//sqlite3FreeX(x)
+#define sqliteFree(x)          sqlite3FreeX(x)
 #define sqliteAllocSize(x)     sqlite3AllocSize(x)
 
 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to