Segfault when authorizer denies some steps of creating a WITHOUT ROWID table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Segfault when authorizer denies some steps of creating a WITHOUT ROWID table

sqlite-10
#if 0
gcc -s -O2 -o ./sqltest1 sqltest1.c sqlite3.o -ldl -lpthread
exit
#endif

/*
  Test with the command:
    ./sqltest1 2 'create table vt(a integer primary key,b,c) without rowid;'
  It segfaults. If the first argument is 3 or 4 it also segfaults.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"

static int count=-1;
static sqlite3*db;

static int xAuth(void*aux,int act,const char*p3,const char*p4,const char*p5,const char*p6) {
  fprintf(stderr,"%d: %d %s %s %s %s\n",count,act,p3,p4,p5,p6);
  return count--?SQLITE_OK:SQLITE_DENY;
}

int main(int argc,char**argv) {
  if(argc!=3) return 1;
  if(sqlite3_open(":memory:",&db)) return 1;
  count=strtol(argv[1],0,0);
  sqlite3_set_authorizer(db,xAuth,0);
  printf("%d\n",sqlite3_exec(db,argv[2],0,0,0));
  return 0;
}
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Segfault when authorizer denies some steps of creating a WITHOUT ROWID table

Richard Hipp-3
Thanks for providing a succinct test case!  A fix is now check-in on
trunk.  https://www.sqlite.org/src/info/164b1641e346994f

Just FYI, the regression test case was added to TH3
(https://www.sqlite.org/th3.html) rather than in the main source tree
as it is much easier to incorporate there.

On 7/8/18, [hidden email] <[hidden email]> wrote:

> #if 0
> gcc -s -O2 -o ./sqltest1 sqltest1.c sqlite3.o -ldl -lpthread
> exit
> #endif
>
> /*
>   Test with the command:
>     ./sqltest1 2 'create table vt(a integer primary key,b,c) without rowid;'
>   It segfaults. If the first argument is 3 or 4 it also segfaults.
> */
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include "sqlite3.h"
>
> static int count=-1;
> static sqlite3*db;
>
> static int xAuth(void*aux,int act,const char*p3,const char*p4,const
> char*p5,const char*p6) {
>   fprintf(stderr,"%d: %d %s %s %s %s\n",count,act,p3,p4,p5,p6);
>   return count--?SQLITE_OK:SQLITE_DENY;
> }
>
> int main(int argc,char**argv) {
>   if(argc!=3) return 1;
>   if(sqlite3_open(":memory:",&db)) return 1;
>   count=strtol(argv[1],0,0);
>   sqlite3_set_authorizer(db,xAuth,0);
>   printf("%d\n",sqlite3_exec(db,argv[2],0,0,0));
>   return 0;
> }
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users