@@ -1446,12 +1446,15 @@ authorizer_callback(void* user_data, int action, const char* arg1, const char* a
14461446}
14471447
14481448// Maps atom names to SQLite authorizer action codes
1449- static int
1449+ static unsigned int
14501450action_code_from_atom (ErlNifEnv * env , ERL_NIF_TERM atom )
14511451{
1452+ // NOTE: `SQLITE_COPY` is no longer used, this is assigned the code 0, we
1453+ // can safely ignore it here and avoid the pesky signed integer UB
1454+
14521455 char buf [32 ];
14531456 if (!enif_get_atom (env , atom , buf , sizeof (buf ), ERL_NIF_LATIN1 )) {
1454- return -1 ;
1457+ return 0 ;
14551458 }
14561459 buf [31 ] = 0 ;
14571460
@@ -1555,7 +1558,7 @@ action_code_from_atom(ErlNifEnv* env, ERL_NIF_TERM atom)
15551558 return SQLITE_RECURSIVE ;
15561559 }
15571560
1558- return -1 ;
1561+ return 0 ;
15591562}
15601563
15611564// set_authorizer(conn, deny_list) -> :ok | {:error, reason}
@@ -1602,8 +1605,8 @@ exqlite_set_authorizer(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
16021605 int new_deny [AUTHORIZER_DENY_SIZE ] = {0 };
16031606 ERL_NIF_TERM head , tail = argv [1 ];
16041607 while (enif_get_list_cell (env , tail , & head , & tail )) {
1605- int code = action_code_from_atom (env , head );
1606- if (code < 0 || code >= AUTHORIZER_DENY_SIZE ) {
1608+ unsigned int code = action_code_from_atom (env , head );
1609+ if (code == 0 ) {
16071610 connection_release_lock (conn );
16081611 return enif_make_badarg (env );
16091612 }
0 commit comments