Skip to content
Snippets Groups Projects
  1. Dec 09, 2024
  2. Apr 17, 2023
    • Ilya Verbin's avatar
      cmake: always define TARGET_OS_* to 0 or 1 · 3b167cf3
      Ilya Verbin authored
      There is a system include file TargetConditionals.h on macOS, which
      defines TARGET_OS_LINUX (and others) to 0 or 1. On the other side,
      TARGET_OS_LINUX is also defined by trivia/config.h.cmake, but there it
      has another possible values: undefined or 1. This inconsistency causes
      issues like #8445, when TARGET_OS_LINUX is defined (to 0) in one file
      and undefined in another. Let's always define it to 0 or 1.
      
      Closes #8445
      
      NO_DOC=bugfix
      
      (cherry picked from commit 19b53ac3)
      3b167cf3
  3. Oct 25, 2022
    • Serge Petrenko's avatar
      security: check size boundaries for getenv() returns · b86395ff
      Serge Petrenko authored
      getenv() return values cannot be trusted, because an attacker might set
      them. For instance, we shouldn't expect, that getenv() returns a value
      of some sane size.
      
      Another problem is that getenv() returns a pointer to one of
      `char **environ` members, which might change upon next setenv().
      
      Introduce a wrapper, getenv_safe(), which returns the value only when
      it fits in a buffer of a specified size, and copies the value onto the
      buffer. Use this wrapper everywhere in our code.
      
      Below's a slightly decorated output of `grep -rwn getenv ./src --include
      *.c --include *.h --include *.cc --include *.cpp --include *.hpp
      --exclude *.lua.c` as of 2022-10-14.
      `-` marks invalid occurences (comments, for example),
      `*` marks the places that are already guarded before this patch,
      `X` mars the places guarded in this patch, and
      `^` marks places fixed in the next commit:
      
      NO_WRAP
      ```
      * ./src/lib/core/coio_file.c:509:	const char *tmpdir = getenv("TMPDIR");
      X ./src/lib/core/errinj.c:75: const char *env_value = getenv(inj->name);
      - ./src/proc_title.c:202: * that might try to hang onto a getenv() result.)
      - ./src/proc_title.c:241:	* is mandatory to flush internal libc caches on getenv/setenv
      X ./src/systemd.c:54: sd_unix_path = getenv("NOTIFY_SOCKET");
      * ./src/box/module_cache.c:300: const char *tmpdir = getenv("TMPDIR");
      X ./src/box/sql/os_unix.c:1441: azDirs[0] = getenv("SQL_TMPDIR");
      X ./src/box/sql/os_unix.c:1446: azDirs[1] = getenv("TMPDIR");
      * ./src/box/lua/console.c:394: const char *envvar = getenv("TT_CONSOLE_HIDE_SHOW_PROMPT");
      ^ ./src/box/lua/console.lua:771: local home_dir = os.getenv('HOME')
      ^ ./src/box/lua/load_cfg.lua:1007: local raw_value = os.getenv(env_var_name)
      X ./src/lua/init.c:575: const char *path = getenv(envname);
      X ./src/lua/init.c:592: const char *home = getenv("HOME");
      * ./src/find_path.c:77: snprintf(buf, sizeof(buf) - 1, "%s", getenv("_"));
      ```
      NO_WRAP
      
      Part-of #7797
      
      NO_DOC=security
      b86395ff
  4. Mar 24, 2022
    • Aleksandr Lyapunov's avatar
      lib: refactor assoc library a bit · 259a7584
      Aleksandr Lyapunov authored
      - Use uint32_t for string length. Actually internally it cannot
      take more that INT_MAX length, so uin32_t is enough. This change
      makes the hash table a bit more compact.
      - Rename mh_strnptr_find_inp -> mh_strnptr_find_str. I beleive it
      makes it more understandable.
      
      NO_DOC=refactoring
      NO_CHANGELOG=refactoring
      NO_TEST=refactoring
      259a7584
  5. Sep 28, 2021
  6. Apr 14, 2021
    • Cyrill Gorcunov's avatar
      box/module_cache: introduce modules subsystem · d3b835de
      Cyrill Gorcunov authored
      
      The modules subsystem hides some low-level operations under API.
      In particular the modules subsystem is responsible for
      
       - modules lookup in Lua's "package.search" storage
       - modules caching to eliminate expensive load procedure
       - function symbol resolving
      
      Because naming is intersecting with current module functions
      sitting in box/func, lets rename the later to schema_module
      prefix. We will use this prefix in next patches to point the
      modules in box.schema.func are just a particular user of
      the general modules engine.
      
      Part-of #4642
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      d3b835de
Loading