Skip to content

Libsodium fixes#8420

Closed
chrisbra wants to merge 8 commits intovim:masterfrom
chrisbra:libsodium_fixes
Closed

Libsodium fixes#8420
chrisbra wants to merge 8 commits intovim:masterfrom
chrisbra:libsodium_fixes

Conversation

@chrisbra
Copy link
Member

Some more or less small fixes for using libsodium:

  • correctly build with MSVC (fixes Cannot build with libsodium with MSVC 2019 on Windows 10 #8411)
  • correctly disable swapfile only when the key option is set
  • comment out some unused functions, so that coverage will increase
  • Drop "corrupted chunk" in error message
  • Fix Coverity issue 1486250 and 1486249 (this is on top of Dominiques fix!)
  • calculate header length over all crypt methods (instead of hard coding)

@codecov
Copy link

codecov bot commented Jun 21, 2021

Codecov Report

Merging #8420 (e495cc8) into master (2ac4b25) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8420      +/-   ##
==========================================
+ Coverage   89.81%   89.86%   +0.05%     
==========================================
  Files         149      149              
  Lines      167792   166178    -1614     
==========================================
- Hits       150707   149341    -1366     
+ Misses      17085    16837     -248     
Flag Coverage Δ
huge-clang-none 88.75% <100.00%> (-0.20%) ⬇️
huge-gcc-none 89.42% <100.00%> (+0.14%) ⬆️
huge-gcc-testgui 87.99% <100.00%> (+0.21%) ⬆️
huge-gcc-unittests 2.50% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/crypt.c 85.09% <100.00%> (+15.33%) ⬆️
src/fileio.c 84.87% <100.00%> (-0.39%) ⬇️
src/memline.c 88.76% <100.00%> (ø)
src/help.c 89.76% <0.00%> (-1.08%) ⬇️
src/textobject.c 91.69% <0.00%> (-0.71%) ⬇️
src/drawline.c 84.95% <0.00%> (-0.55%) ⬇️
src/ex_cmds2.c 90.93% <0.00%> (-0.54%) ⬇️
src/beval.c 82.81% <0.00%> (-0.53%) ⬇️
src/netbeans.c 84.04% <0.00%> (-0.52%) ⬇️
src/mbyte.c 80.09% <0.00%> (-0.52%) ⬇️
... and 64 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ac4b25...e495cc8. Read the comment docs.

chrisbra added 7 commits June 21, 2021 19:10
The inplace encoding and decoding functions using xchacha20 are not
actually used. The actual buffer will be en/decoded using the
crypt_sodium_buffer_encode/decode() function, which buffers the
input (to be able to add padding and the MAC).

Those inplace encoding functions would be used for handling the swap and
undo file. However, since those features are currently explicitly
disabled, comment out those functions. The code will be kept, just in
case we will ever make swapfile or undo file encoding work :/

This should at least gain us some coverage, since there is currently no way
to test those functions.
To correctly calculate the block size for reading a file, we need to
know what metadata is added in addition to the payload.

Instead of hard-coding the used header-length, let's calculate the
maximum needed header length for all available crypt methods and use
that one.
Fix the Coverity issues 1486250 and 1486249 by checking whether a length
has been specified or not, and only if one was given, access the actual
buffer pointer.
Only disable the swapfile, if the key option for a given buffer has been
set. Do not disable it just because the cryptmethod was set.
The error messages "Corrupted chunk" may be misleading, since it is also
given when a wrong password was entered. So simply drop that part and
only output that the decryption failed.
fixes vim#8411

add the include directory to the CFLAGS variable, instead of the $INCL
variable.

Also fix a typo for the 32bit includes and finally change the Include
switch to use `/I` instead of `-I`, quoting the sodium directory.
@chrisbra chrisbra force-pushed the libsodium_fixes branch 2 times, most recently from 8cb8902 to 931ebc6 Compare June 21, 2021 17:17
@chrisbra
Copy link
Member Author

amended to fix test failures and also fix a conversion warning from MSVC

@brammool
Copy link
Contributor

Some code is disabled with "#if 0", was that for testing/debugging?

@brammool
Copy link
Contributor

ah, I see the "Currently unused," comment applies to that.

@brammool brammool closed this in 226b28b Jun 21, 2021
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 31, 2021
Problem:    Location list only has the start position.
Solution:   Make it possible to add an end position. (Shane-XB-Qian,
            closes vim/vim#8393)
vim/vim@6864efa

N/A patches for version.c:

vim-patch:8.2.3002: Vim doesn't abort on a fatal Tcl error

Problem:    Vim doesn't abort on a fatal Tcl error.
Solution:   Change emsg() to iemsg(). (Dominique Pellé, closes vim/vim#8383)
vim/vim@affd0bc

vim-patch:8.2.3030: Coverity reports a memory leak

Problem:    Coverity reports a memory leak.
Solution:   Fix the leak and a few typos. (Dominique Pellé, closes vim/vim#8418)
vim/vim@cb54bc6

Patch v8.2.3022 is mostly N/A but cannot be included here
because of new feature check for "has()".

vim-patch:8.2.3032: build problems with MSVC, other crypt issues with libsodium

Problem:    Build problems with MSVC, other crypt issues with libsodium.
Solution:   Adjust MSVC makefile. Disable swap file only when 'key' is set.
            Adjust error message used when key is wrong.  Fix Coverity issues.
            (Christian Brabandt, closes vim/vim#8420, closes vim/vim#8411)
vim/vim@226b28b

vim-patch:8.2.3044: Amiga MorphOS and AROS: process ID is not valid

Problem:    Amiga MorphOS and AROS: process ID is not valid.
Solution:   Use FindTask to return something which is unique to all processes.
            (Ola Söder, closes vim/vim#8444)
vim/vim@3a62b14

vim-patch:8.2.3046: Amiga MorphOS: Term mode is set using DOS packets

Problem:    Amiga MorphOS: Term mode is set using DOS packets.
Solution:   Use the same way of setting term mdoe on all next gen Amiga-like
            systems.  (Ola Söder, closes vim/vim#8445)
vim/vim@b420ac9
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    Location list only has the start position.
Solution:   Make it possible to add an end position. (Shane-XB-Qian,
            closes vim/vim#8393)
vim/vim@6864efa

N/A patches for version.c:

vim-patch:8.2.3002: Vim doesn't abort on a fatal Tcl error

Problem:    Vim doesn't abort on a fatal Tcl error.
Solution:   Change emsg() to iemsg(). (Dominique Pellé, closes vim/vim#8383)
vim/vim@affd0bc

vim-patch:8.2.3030: Coverity reports a memory leak

Problem:    Coverity reports a memory leak.
Solution:   Fix the leak and a few typos. (Dominique Pellé, closes vim/vim#8418)
vim/vim@cb54bc6

Patch v8.2.3022 is mostly N/A but cannot be included here
because of new feature check for "has()".

vim-patch:8.2.3032: build problems with MSVC, other crypt issues with libsodium

Problem:    Build problems with MSVC, other crypt issues with libsodium.
Solution:   Adjust MSVC makefile. Disable swap file only when 'key' is set.
            Adjust error message used when key is wrong.  Fix Coverity issues.
            (Christian Brabandt, closes vim/vim#8420, closes vim/vim#8411)
vim/vim@226b28b

vim-patch:8.2.3044: Amiga MorphOS and AROS: process ID is not valid

Problem:    Amiga MorphOS and AROS: process ID is not valid.
Solution:   Use FindTask to return something which is unique to all processes.
            (Ola Söder, closes vim/vim#8444)
vim/vim@3a62b14

vim-patch:8.2.3046: Amiga MorphOS: Term mode is set using DOS packets

Problem:    Amiga MorphOS: Term mode is set using DOS packets.
Solution:   Use the same way of setting term mdoe on all next gen Amiga-like
            systems.  (Ola Söder, closes vim/vim#8445)
vim/vim@b420ac9
@chrisbra chrisbra deleted the libsodium_fixes branch September 10, 2025 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot build with libsodium with MSVC 2019 on Windows 10

2 participants