diff --git a/Makefile b/Makefile index 93adfa2106e729af36858e80ff1d19241f00384a..67baec9d34b6923ab26193b59d69f6643005443c 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,10 @@ tarantool-patch: echo "${VER_TNT}" > tarantool-sys/VERSION PICODATA_DIR=$(shell find / -type d -name "picodata" 2>/dev/null | grep -v helm) PATCH_DIR=$${PICODATA_DIR}/certification_patches/svace_patches + (cd $${PICODATA_DIR}/tarantool-sys; find $${PATCH_DIR} -name "tarantool-sys_*" | xargs -n 1 git apply) (cd $${PICODATA_DIR}/tarantool-sys/third_party/luajit; find $${PATCH_DIR} -name "luajit_*" | xargs -n 1 git apply) + build: tarantool-patch . ~/.cargo/env && \ cargo build --locked --features webui diff --git a/certification_patches/svace_patches/luajit_lj_udata.patch b/certification_patches/svace_patches/luajit_lj_udata.patch new file mode 100644 index 0000000000000000000000000000000000000000..82723902b9baf0983f1d8ca6eb5535a5431d9c1d --- /dev/null +++ b/certification_patches/svace_patches/luajit_lj_udata.patch @@ -0,0 +1,21 @@ +diff --git a/src/lj_udata.c b/src/lj_udata.c +index 1b7841fa..22426dbb 100644 +--- a/src/lj_udata.c ++++ b/src/lj_udata.c +@@ -6,6 +6,8 @@ + #define lj_udata_c + #define LUA_CORE + ++#include <assert.h> ++ + #include "lj_obj.h" + #include "lj_gc.h" + #include "lj_err.h" +@@ -57,6 +59,7 @@ void *lj_lightud_intern(lua_State *L, void *p) + setmref(g->gc.lightudseg, segmap); + } + g->gc.lightudnum = segnum; ++ assert(segmap != NULL); + segmap[segnum] = up; + return (void *)(((uint64_t)segnum << LJ_LIGHTUD_BITS_LO) | lightudlo(u)); + } diff --git a/certification_patches/svace_patches/tarantool-sys_alter.patch b/certification_patches/svace_patches/tarantool-sys_alter.patch new file mode 100644 index 0000000000000000000000000000000000000000..b927e906392168b944139b2ef8d68dc9a7a2df28 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_alter.patch @@ -0,0 +1,41 @@ +diff --git a/src/box/alter.cc b/src/box/alter.cc +index 7aeab4648..7b8cd489c 100644 +--- a/src/box/alter.cc ++++ b/src/box/alter.cc +@@ -1774,6 +1774,7 @@ alter_space_move_indexes(struct alter_space *alter, uint32_t begin, + old_def->name, strlen(old_def->name), + old_def->type, &old_def->opts, + old_def->key_def, alter->pk_def); ++ assert(new_def != NULL); + index_def_update_optionality(new_def, min_field_count); + auto guard = make_scoped_guard([=] { index_def_delete(new_def); }); + if (!index_def_change_requires_rebuild(old_index, new_def)) +@@ -2996,6 +2997,8 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) + return -1; + txn_stmt_on_rollback(stmt, on_rollback); + } else if (new_tuple == NULL) { /* DELETE */ ++ if (old_user == NULL) ++ return -1; /* using if instead of assert for svace */ + if (access_check_ddl(old_user->def->name, old_user->def->uid, + old_user->def->owner, old_user->def->type, + BOX_PRIVILEGE_DROP) != 0) +@@ -3353,6 +3356,8 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event) + if (trigger_run(&on_alter_func, func) != 0) + return -1; + } else if (new_tuple == NULL) { /* DELETE */ ++ if (old_func == NULL) ++ return -1; /* using if instead of assert for svace */ + uint32_t uid; + if (func_def_get_ids_from_tuple(old_tuple, &fid, &uid) != 0) + return -1; +@@ -4392,7 +4397,9 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event) + sequence_cache_delete(seq->def->id); + txn_stmt_on_commit(stmt, on_commit); + txn_stmt_on_rollback(stmt, on_rollback); +- } else { /* UPDATE */ ++ } else { ++ if (new_tuple == NULL) /* UPDATE */ ++ return -1; /* using if instead of assert for svace */ + new_def = sequence_def_new_from_tuple(new_tuple, + ER_ALTER_SEQUENCE); + if (new_def == NULL) diff --git a/certification_patches/svace_patches/tarantool-sys_bps_tree.patch b/certification_patches/svace_patches/tarantool-sys_bps_tree.patch new file mode 100644 index 0000000000000000000000000000000000000000..b43b55e89c18ca2e40ad7c92ae794d8e2a3d8eda --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_bps_tree.patch @@ -0,0 +1,12 @@ +diff --git a/src/lib/salad/bps_tree.h b/src/lib/salad/bps_tree.h +index e340588cb..7cdeb9770 100644 +--- a/src/lib/salad/bps_tree.h ++++ b/src/lib/salad/bps_tree.h +@@ -1585,6 +1585,7 @@ bps_tree_random(const struct bps_tree *t, size_t rnd) + for (bps_tree_block_id_t i = 0; i < tree->depth - 1; i++) { + struct bps_inner *inner = (struct bps_inner *)block; + bps_tree_pos_t pos = rnd % inner->header.size; ++ assert(pos < BPS_TREE_MAX_COUNT_IN_INNER); + rnd /= inner->header.size; + block = bps_tree_restore_block(tree, inner->child_ids[pos]); + } diff --git a/certification_patches/svace_patches/tarantool-sys_build.patch b/certification_patches/svace_patches/tarantool-sys_build.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5ba95e20bbfbee61d0cd05ecd05bfe6b7021e27 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_build.patch @@ -0,0 +1,28 @@ +diff --git a/src/box/sql/build.c b/src/box/sql/build.c +index 6891de805..78428e9f9 100644 +--- a/src/box/sql/build.c ++++ b/src/box/sql/build.c +@@ -1300,7 +1300,13 @@ vdbe_emit_create_constraints(struct Parse *parse, int reg_space_id) + */ + if (is_alter) { + space = parse->create_column_def.space; +- i = space_by_name(space->def->name)->index_count; ++ struct space *space_obj = space_by_name(space->def->name); ++ if (space_obj == NULL) { ++ diag_set(ClientError, ER_NO_SUCH_SPACE, space->def->name); ++ parse->is_aborted = true; ++ return; ++ } ++ i = space_obj->index_count; + } + assert(space != NULL); + for (; i < space->index_count; ++i) { +@@ -2098,7 +2104,7 @@ sql_create_foreign_key(struct Parse *parse_context) + constraint_name) != 0) + goto exit_create_fk; + /* In case of ALTER parent table must exist. */ +- } else if (columnno_by_name(parse_context, child_space, ++ } else if (child_cols && columnno_by_name(parse_context, child_space, + child_cols->a[i].zName, + &fk_def->links[i].child_field, + constraint_name) != 0) { diff --git a/certification_patches/svace_patches/tarantool-sys_eio.patch b/certification_patches/svace_patches/tarantool-sys_eio.patch new file mode 100644 index 0000000000000000000000000000000000000000..26feeb998efca904d320c7c99649556a478489a6 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_eio.patch @@ -0,0 +1,26 @@ +diff --git a/third_party/libeio/eio.c b/third_party/libeio/eio.c +index 03cb010e4..513ac2461 100644 +--- a/third_party/libeio/eio.c ++++ b/third_party/libeio/eio.c +@@ -1408,8 +1408,12 @@ eio__scandir (eio_req *req, etp_worker *self) + req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; + req->ptr2 = names = malloc (namesalloc); + +- if (!names || (flags && !dents)) ++ if (!names || (flags && !dents)) { ++#ifndef _WIN32 ++ closedir (dirp); ++#endif + return; ++ } + + for (;;) + { +@@ -2250,6 +2254,7 @@ eio__2path (int type, const char *path, const char *new_path, int pri, eio_cb cb + req->ptr2 = strdup (new_path); + if (!req->ptr2) + { ++ free(req->ptr1); + eio_api_destroy (req); + return 0; + } diff --git a/certification_patches/svace_patches/tarantool-sys_ev.patch b/certification_patches/svace_patches/tarantool-sys_ev.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5f5145e0a687e4e5276ccf008393ffdae7c0b14 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_ev.patch @@ -0,0 +1,57 @@ +diff --git a/third_party/libev/ev.c b/third_party/libev/ev.c +index 43e4815b8..b46a8f324 100644 +--- a/third_party/libev/ev.c ++++ b/third_party/libev/ev.c +@@ -2264,10 +2264,12 @@ array_nextsize (int elem, int cur, int cnt) + ncur <<= 1; + while (cnt > ncur); + ++ assert((unsigned long)elem * (unsigned long)ncur <= INT_MAX); + /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ +- if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) ++ if ((unsigned long)elem * (unsigned long)ncur > MALLOC_ROUND - sizeof (void *) * 4) + { + ncur *= elem; ++ assert(((unsigned long)ncur + (unsigned long)elem + ((unsigned long)(MALLOC_ROUND - 1)) + sizeof (void *) * 4) <= INT_MAX); + ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); + ncur = ncur - sizeof (void *) * 4; + ncur /= elem; +@@ -2281,7 +2283,7 @@ static void * + array_realloc (int elem, void *base, int *cur, int cnt) + { + *cur = array_nextsize (elem, *cur, cnt); +- return ev_realloc (base, elem * *cur); ++ return ev_realloc (base, (long)elem * ((long)(*cur))); + } + + #define array_needsize_noinit(base,offset,count) +@@ -2852,7 +2854,13 @@ pipecb (EV_P_ ev_io *iow, int revents) + if (evpipe [0] < 0) + { + uint64_t counter; +- read (evpipe [1], &counter, sizeof (uint64_t)); ++ ssize_t bytes_read = read (evpipe [1], &counter, sizeof (uint64_t)); ++ if (bytes_read < 0) { ++ ev_syserr("(libev) error reading signal/async pipe"); ++ ++ } else if (bytes_read != sizeof (uint64_t)) { ++ ev_syserr("(libev) error not full reading signal/async pipe"); ++ } + } + else + #endif +@@ -2866,7 +2874,13 @@ pipecb (EV_P_ ev_io *iow, int revents) + buf.len = sizeof (dummy); + WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, &flags, 0, 0); + #else +- read (evpipe [0], &dummy, sizeof (dummy)); ++ ssize_t bytes_read = read (evpipe [0], &dummy, sizeof (dummy)); ++ if (bytes_read < 0) { ++ ev_syserr("(libev) error reading signal/async pipe"); ++ ++ } else if (bytes_read != sizeof (dummy)) { ++ ev_syserr("(libev) error not full reading signal/async pipe"); ++ } + #endif + } + } diff --git a/certification_patches/svace_patches/tarantool-sys_ev_epoll.patch b/certification_patches/svace_patches/tarantool-sys_ev_epoll.patch new file mode 100644 index 0000000000000000000000000000000000000000..af587c0c12054c5af0c217893ebdd63ea9119fcf --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_ev_epoll.patch @@ -0,0 +1,15 @@ +diff --git a/third_party/libev/ev_epoll.c b/third_party/libev/ev_epoll.c +index 58cfa684d..ca22c6351 100644 +--- a/third_party/libev/ev_epoll.c ++++ b/third_party/libev/ev_epoll.c +@@ -99,8 +99,8 @@ epoll_modify (EV_P_ int fd, int oev, int nev) + if (ecb_expect_true (errno == ENOENT)) + { + /* if ENOENT then the fd went away, so try to do the right thing */ +- if (!nev) +- goto dec_egen; ++ // if (!nev) ++ // goto dec_egen; + + if (!epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev)) + return; diff --git a/certification_patches/svace_patches/tarantool-sys_ev_iouring.patch b/certification_patches/svace_patches/tarantool-sys_ev_iouring.patch new file mode 100644 index 0000000000000000000000000000000000000000..950e535f663c10651a0127c2af5414d526c7dec7 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_ev_iouring.patch @@ -0,0 +1,19 @@ +diff --git a/third_party/libev/ev_iouring.c b/third_party/libev/ev_iouring.c +index 23788ea24..e47942e19 100644 +--- a/third_party/libev/ev_iouring.c ++++ b/third_party/libev/ev_iouring.c +@@ -351,8 +351,12 @@ ecb_cold + static int + iouring_internal_destroy (EV_P) + { +- close (iouring_tfd); +- close (iouring_fd); ++ if (iouring_tfd > 0) { ++ close (iouring_tfd); ++ } ++ if (iouring_fd > 0) { ++ close (iouring_fd); ++ } + + if (iouring_ring != MAP_FAILED) munmap (iouring_ring, iouring_ring_size); + if (iouring_sqes != MAP_FAILED) munmap (iouring_sqes, iouring_sqes_size); diff --git a/certification_patches/svace_patches/tarantool-sys_expr.patch b/certification_patches/svace_patches/tarantool-sys_expr.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ff1844f285be28d69a32ed1946e2e5ed4d38366 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_expr.patch @@ -0,0 +1,14 @@ +diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c +index 3a2426bcd..4865f7865 100644 +--- a/src/box/sql/expr.c ++++ b/src/box/sql/expr.c +@@ -1879,7 +1879,8 @@ sqlExprListSetName(Parse * pParse, /* Parsing context */ + } else { + item->zName = sql_xstrndup(pName->z, pName->n); + } +- sqlCheckIdentifierName(pParse, item->zName); ++ if (sqlCheckIdentifierName(pParse, item->zName) < 0) ++ sql_xfree(item->zName); + } + + void diff --git a/certification_patches/svace_patches/tarantool-sys_lemon.patch b/certification_patches/svace_patches/tarantool-sys_lemon.patch new file mode 100644 index 0000000000000000000000000000000000000000..762c7a06e54c6d8fd0d677932cd571f058506ad5 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_lemon.patch @@ -0,0 +1,19 @@ +diff --git a/extra/lemon.c b/extra/lemon.c +index f5450ef83..8d5242617 100644 +--- a/extra/lemon.c ++++ b/extra/lemon.c +@@ -1876,9 +1876,11 @@ static FILE *errstream; + */ + static void errline(int n, int k, FILE *err) + { +- int spcnt, i; +- if( argv[0] ) fprintf(err,"%s",argv[0]); +- spcnt = lemonStrlen(argv[0]) + 1; ++ int spcnt = 0, i; ++ if( argv[0] ) { ++ fprintf(err,"%s",argv[0]); ++ spcnt = lemonStrlen(argv[0]) + 1; ++ } + for(i=1; i<n && argv[i]; i++){ + fprintf(err," %s",argv[i]); + spcnt += lemonStrlen(argv[i])+1; diff --git a/certification_patches/svace_patches/tarantool-sys_memtx_tx.patch b/certification_patches/svace_patches/tarantool-sys_memtx_tx.patch new file mode 100644 index 0000000000000000000000000000000000000000..baf5cb61ed14dd78adec1782185e35da82193b4a --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_memtx_tx.patch @@ -0,0 +1,12 @@ +diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c +index ec78ceaa5..e177f20b5 100644 +--- a/src/box/memtx_tx.c ++++ b/src/box/memtx_tx.c +@@ -2121,6 +2121,7 @@ memtx_tx_history_add_insert_stmt(struct txn_stmt *stmt, + del_story = replaced_story; + else + del_story = memtx_tx_story_get(old_tuple); ++ assert(del_story != NULL); + memtx_tx_story_link_deleted_by(del_story, stmt); + } else if (is_own_change) + stmt->is_pure_insert = true; diff --git a/certification_patches/svace_patches/tarantool-sys_say.patch b/certification_patches/svace_patches/tarantool-sys_say.patch new file mode 100644 index 0000000000000000000000000000000000000000..b105ba730282333a6c96d4c5bb7f9d20375be6b3 --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_say.patch @@ -0,0 +1,12 @@ +diff --git a/src/lib/core/say.c b/src/lib/core/say.c +index a80880724..2ab3d5478 100644 +--- a/src/lib/core/say.c ++++ b/src/lib/core/say.c +@@ -655,6 +655,7 @@ log_syslog_init(struct log *log, const char *init_str) + else + log->syslog_ident = strdup(opts.identity); + if (log->syslog_ident == NULL) { ++ assert(opts.identity != NULL); + diag_set(OutOfMemory, strlen(opts.identity), "malloc", + "log->syslog_ident"); + return -1; diff --git a/certification_patches/svace_patches/tarantool-sys_select.patch b/certification_patches/svace_patches/tarantool-sys_select.patch new file mode 100644 index 0000000000000000000000000000000000000000..1eadce4d9608a4721fbe965f34741133bd7d558d --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_select.patch @@ -0,0 +1,12 @@ +diff --git a/src/box/sql/select.c b/src/box/sql/select.c +index e58bd10fb..e4ac834b2 100644 +--- a/src/box/sql/select.c ++++ b/src/box/sql/select.c +@@ -2122,6 +2122,7 @@ sqlColumnsFromExprList(Parse * parse, ExprList * expr_list, + } + zName = sqlMPrintf("%.*z_%u", nName, zName, ++cnt); + } ++ assert(zName != NULL); + size_t name_len = strlen(zName); + void *field = &space_def->fields[i]; + assert(field != NULL); diff --git a/certification_patches/svace_patches/tarantool-sys_wherecode.patch b/certification_patches/svace_patches/tarantool-sys_wherecode.patch new file mode 100644 index 0000000000000000000000000000000000000000..7bbb4a51df6e8f8efd35aefd6fb9da5d2305d29d --- /dev/null +++ b/certification_patches/svace_patches/tarantool-sys_wherecode.patch @@ -0,0 +1,13 @@ +diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c +index 8cac15123..5f084394f 100644 +--- a/src/box/sql/wherecode.c ++++ b/src/box/sql/wherecode.c +@@ -458,7 +458,7 @@ codeEqualityTerm(Parse * pParse, /* The parsing context */ + * such a vector, some of the subroutines do not handle + * this case. + */ +- if (pLhs->nExpr == 1) { ++ if (pLhs && pLhs->nExpr == 1) { + pX->pLeft = pLhs->a[0].pExpr; + } else { + pLeft->x.pList = pLhs;