keepass-diff icon indicating copy to clipboard operation
keepass-diff copied to clipboard

regression with v1.2.0 (vs 1.1.4)

Open shuther opened this issue 1 year ago • 9 comments

I was just comparing 2 files with v1.1.4 and it worked as expected, then I installed the latest version with cargo and I end up with a corrupt database? The files are expected to both work. Replaced package keepass-diff v1.1.4 with keepass-diff v1.2.0 (executable keepass-diff)

RUST_BACKTRACE=1 keepass-diff --same-password "yyy(2024-01-20 180921).kdbx" "xxx.kdbx"

Password for both files: 
thread 'main' panicked at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/keepass-diff-1.2.0/src/main.rs:122:18:
Error opening database A: DatabaseIntegrity(Xml(BadEvent { expected: "text containing a value", event: End("Data") }))
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: keepass_diff::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
shuther@ubuntu-vm:/mnt/smb/documents/shuther/nextcloud/Documents/Perso/keepw$ RUST_BACKTRACE=full keepass-diff  --same-password  "xxx-osx (2024-01-20 180921).kdbx" "xxx-osx.kdbx" 
Password for both files: 
thread 'main' panicked at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/keepass-diff-1.2.0/src/main.rs:122:18:
Error opening database A: DatabaseIntegrity(Xml(BadEvent { expected: "text containing a value", event: End("Data") }))
stack backtrace:
   0:     0x5580507c8e06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h410d4c66be4e37f9
   1:     0x5580507e98a0 - core::fmt::write::he40921d4802ce2ac
   2:     0x5580507c6e3f - std::io::Write::write_fmt::h5de5a4e7037c9b20
   3:     0x5580507c8be4 - std::sys_common::backtrace::print::h11c067a88e3bdb22
   4:     0x5580507ca147 - std::panicking::default_hook::{{closure}}::h8c832ecb03fde8ea
   5:     0x5580507c9ea9 - std::panicking::default_hook::h1633e272b4150cf3
   6:     0x5580507ca5d8 - std::panicking::rust_panic_with_hook::hb164d19c0c1e71d4
   7:     0x5580507ca4b2 - std::panicking::begin_panic_handler::{{closure}}::h0369088c533c20e9
   8:     0x5580507c9306 - std::sys_common::backtrace::__rust_end_short_backtrace::hc11d910daf35ac2e
   9:     0x5580507ca204 - rust_begin_unwind
  10:     0x5580506cba15 - core::panicking::panic_fmt::ha6effc2775a0749c
  11:     0x5580506cbe83 - core::result::unwrap_failed::ha188096f98826595
  12:     0x5580506d7082 - keepass_diff::main::h9ae5aec15cd8feea
  13:     0x5580506e7683 - std::sys_common::backtrace::__rust_begin_short_backtrace::h30b910d3657988f1
  14:     0x5580506ea61c - std::rt::lang_start::{{closure}}::hd561d120cee572dd
  15:     0x5580507c22e1 - std::rt::lang_start_internal::h4d236095b69a230b
  16:     0x5580506de0b5 - main
  17:     0x7f1cf992fd90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  18:     0x7f1cf992fe40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  19:     0x5580506cc145 - _start
  20:                0x0 - <unknown>

If I could see the string or the key I should be able to confirm the date (valid or not); hope it helps

shuther avatar Apr 17 '24 14:04 shuther

same issue. t``` hread 'main' panicked at /home/shuther/.cargo/registry/src/index.crates.io-6f17d22bba15001f/keepass-diff-1.2.0/src/main.rs:122:18: Error opening database A: DatabaseIntegrity(Xml(BadEvent { expected: "text containing a value", event: End("Data") })) stack backtrace: 0: 0x557214edbe06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h410d4c66be4e37f9 1: 0x557214efc8a0 - core::fmt::write::he40921d4802ce2ac 2: 0x557214ed9e3f - std::io::Write::write_fmt::h5de5a4e7037c9b20 3: 0x557214edbbe4 - std::sys_common::backtrace::print::h11c067a88e3bdb22 4: 0x557214edd147 - std::panicking::default_hook::{{closure}}::h8c832ecb03fde8ea 5: 0x557214edcea9 - std::panicking::default_hook::h1633e272b4150cf3 6: 0x557214edd5d8 - std::panicking::rust_panic_with_hook::hb164d19c0c1e71d4 7: 0x557214edd4b2 - std::panicking::begin_panic_handler::{{closure}}::h0369088c533c20e9 8: 0x557214edc306 - std::sys_common::backtrace::__rust_end_short_backtrace::hc11d910daf35ac2e 9: 0x557214edd204 - rust_begin_unwind 10: 0x557214ddea15 - core::panicking::panic_fmt::ha6effc2775a0749c 11: 0x557214ddee83 - core::result::unwrap_failed::ha188096f98826595 12: 0x557214dea082 - keepass_diff::main::h9ae5aec15cd8feea 13: 0x557214dfa683 - std::sys_common::backtrace::__rust_begin_short_backtrace::h30b910d3657988f1 14: 0x557214dfd61c - std::rt::lang_start::{{closure}}::hd561d120cee572dd 15: 0x557214ed52e1 - std::rt::lang_start_internal::h4d236095b69a230b 16: 0x557214df10b5 - main 17: 0x7fe066bb1d90 - __libc_start_call_main at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 18: 0x7fe066bb1e40 - __libc_start_main_impl at ./csu/../csu/libc-start.c:392:3 19: 0x557214ddf145 - _start 20: 0x0 -

shuther avatar May 08 '24 13:05 shuther

it is working fine with 1.1.3 with: RUSTFLAGS="-C target-cpu=native" cargo install --version 1.1.3 keepass-diff

shuther avatar May 08 '24 13:05 shuther

Thank you for reporting @shuther and sorry for checking back here so late!

If I remember correctly, there have been some bigger updates to the underlying lib between 1.1.x and 1.2.0. Looking at the error message, it sounds like there are issues parsing the database file. I suspect that either the regular client you're working with is saving the database in some strange way or the keepass-rs library is not capable of parsing something that you're saving in your database. Maybe storing files or notes or something else in the database? I mean, maybe some feature that is not being used in the current tests could create this. Since it worked previously it sounds more like a regression to me, but I don't know the keepass specification and never worked on the low level there 😬

In general, it would be very helpful to have a reproducer - you might be able to create one based on your currently not working database. Workflow would be to copy it, remove entries until I find the one that causes the issue, then check what this entry has that others don't, then create a new database with just that and check if it's still problematic. I know this could be tedious and long, but it would be a good addition to the existing tests. Most probably, there has been a new release for keepass-rs though and it may have fixed this issue already. Checking this would be to update the dependency in our Cargo.toml, build it with the newer version of the dependency and hope that it already works. If it still doesn't, we need to open an issue against keepass-rs.

Narigo avatar Jun 16 '24 22:06 Narigo

So I took my original file, I emptied it completely and deleted the recycle bin (within keepass-xc) and I still face the issue. What is strange is the size of this new file; even save as backup from keepass-xc is generating a file as big as the original one and I can't find a compact option somewhere. Would you know where to submit these different issues ?

shuther avatar Jun 19 '24 09:06 shuther

linked to issue

shuther avatar Jun 19 '24 09:06 shuther

Never saw that...! Did you save the file and closed keepass-xc after doing this? Are you sure no process is still keeping the file open so it doesn't actually change after saving it with new contents?

Narigo avatar Jun 19 '24 20:06 Narigo

I think I identified the problem while going through the xml. I have Items with proper dates in but with different format. I am not sure if it is expected (from Keepassxc) or not; and where should it be fixed (for read, and for write). Maybe keepass-diff should ignore this section?

			<Item>
				<Key>_LAST_MODIFIED</Key>
				<Value>Thu Jun 20 13:10:15 2024 GMT</Value>
			</Item>
			<Item>
				<Key>_CREATED_xxxst</Key>
				<Value>11-Sep-22 15:59</Value>
				<LastModificationTime>suCv2g4AAAA=</LastModificationTime>
			</Item>
		<Item>
				<Key>_CREATED_chrome laptop</Key>
				<Value>07/03/2023 11:34</Value>
				<LastModificationTime>KQqZ2w4AAAA=</LastModificationTime>
			</Item>
		<Item>
				<Key>_CREATED_xxxmac 1</Key>
				<Value>24.09.22 11:58</Value>
				<LastModificationTime>ssvA2g4AAAA=</LastModificationTime>
			</Item>
		<Item>
				<Key>_CREATED_xxx-1</Key>
				<Value>2023-11-28 1:37 PM</Value>
				<LastModificationTime>9dX33A4AAAA=</LastModificationTime>
			</Item>

shuther avatar Jun 22 '24 17:06 shuther

I too had the same error/bug happen .. reverting to 1.1.3 worked.

thread 'main' panicked at src/main.rs:122:18:
Error opening database A: DatabaseIntegrity(Xml(BadEvent { expected: "text containing a value", event: End("Data") }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

shadowbq avatar Sep 26 '24 20:09 shadowbq

Thanks for this outstanding tool.

I have the same issue with one database created and used with KeePassXC on MacOS and some iOS apps (KyPass and others).

However, I'm using keepass-diff Ubuntu 24.04 on WSL 2. I built it on this Ubuntu using: RUSTFLAGS="-C target-cpu=native" cargo install keepass-diff

I can open the database with keepass2 and keepassxc on Ubuntu, MacOS and Windows. I've also tried to save a it with keepass2 after making changes. But no avail.

As others have reported, it is working fine with 1.1.3: RUSTFLAGS="-C target-cpu=native" cargo install --version 1.1.3 keepass-diff

Is there any further information I can provide? Is it possible to dump the decrypted text (xml before parsing) to see it's validity in an XML tool? If not, that might be a great feature, eg. keepass-diff --dump-raw [--password-a|--no-password-a] [--keyfile-a] INPUT-A

Would it be possible to include the position within the raw text in the trace to more easily identify the data causing the exception?

Thanks.

Versions

$ keepass-diff -V
keepass-diff 1.2.0

$ apt search keepass
keepass2/noble,now 2.47+dfsg-2 all [installed]
  Password manager

keepassxc/now 2.7.10-1ppa2~jammy1 amd64 [installed,local]
  KeePass Cross-Platform Community Edition

~$ uname -a
Linux jaguar 5.15.90.4-microsoft-standard-WSL2+ #1 SMP Fri Aug 4 14:06:36 CEST 2023 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"

Trace

using RUST_BACKTRACE=full

$ export RUST_BACKTRACE=full
$ keepass-diff -v --keyfile-a A.key A.kdbx B.kdbx
Password for file A.kdbx:
Password for file B.kdbx:
thread 'main' panicked at /home/x/.cargo/registry/src/index.crates.io-6f17d22bba15001f/keepass-diff-1.2.0/src/main.rs:124:18:
Error opening database B: DatabaseIntegrity(Xml(BadEvent { expected: "text containing a value", event: End("Data") }))
stack backtrace:
   0:     0x55fc98f5ad4b - std::backtrace_rs::backtrace::libunwind::trace::he991e66e5f22a1db
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x55fc98f5ad4b - std::backtrace_rs::backtrace::trace_unsynchronized::h43f35a5576eecb13
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55fc98f5ad4b - std::sys_common::backtrace::_print_fmt::hf9c799a68b2477fc
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55fc98f5ad4b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2d48dfeb5948660
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55fc98f96d20 - core::fmt::rt::Argument::fmt::h507ca91fbb1ef494
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/rt.rs:142:9
   5:     0x55fc98f96d20 - core::fmt::write::h4d5f6025aa566322
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/mod.rs:1120:17
   6:     0x55fc98f57b5d - std::io::Write::write_fmt::hc088b3c8cc6dcb9f
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/io/mod.rs:1762:15
   7:     0x55fc98f5ab34 - std::sys_common::backtrace::_print::h231201f6cff8f56a
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x55fc98f5ab34 - std::sys_common::backtrace::print::h478d6be486f8cd2d
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x55fc98f7754a - std::panicking::default_hook::{{closure}}::hf1c55106b4d45a90
  10:     0x55fc98f771ed - std::panicking::default_hook::h7b29000c631cc719
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:292:9
  11:     0x55fc98f77968 - std::panicking::rust_panic_with_hook::h2a988919dd121561
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:779:13
  12:     0x55fc98f5b12e - std::panicking::begin_panic_handler::{{closure}}::h3a9eaa1d23ecf555
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:657:13
  13:     0x55fc98f5af66 - std::sys_common::backtrace::__rust_end_short_backtrace::h813561fdec15f700
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x55fc98f77692 - rust_begin_unwind
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:645:5
  15:     0x55fc98e725c5 - core::panicking::panic_fmt::hef0307862026e6f9
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:72:14
  16:     0x55fc98e72c53 - core::result::unwrap_failed::h8393ef8d489acb45
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/result.rs:1653:5
  17:     0x55fc98e7d623 - keepass_diff::main::h9c757b2d494a6b8f
  18:     0x55fc98e8f6b3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8137a7ab507911fa
  19:     0x55fc98e91bfc - std::rt::lang_start::{{closure}}::h8589793fa455aa20
  20:     0x55fc98f77584 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2a98286140a8c485
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/ops/function.rs:284:13
  21:     0x55fc98f77584 - std::panicking::try::do_call::h6f884a82d660d639
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:552:40
  22:     0x55fc98f77584 - std::panicking::try::h3d219ee83761ccf8
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:516:19
  23:     0x55fc98f77584 - std::panic::catch_unwind::h0a8f78f1f5633cdb
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panic.rs:142:14
  24:     0x55fc98f77584 - std::rt::lang_start_internal::{{closure}}::hd36869a5192571c4
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/rt.rs:148:48
  25:     0x55fc98f77584 - std::panicking::try::do_call::hbfe6916f1cc74e35
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:552:40
  26:     0x55fc98f77584 - std::panicking::try::h0cc643a8ace88736
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:516:19
  27:     0x55fc98f651bb - std::panic::catch_unwind::hd66d6c526b1a6302
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panic.rs:142:14
  28:     0x55fc98f651bb - std::rt::lang_start_internal::h8fc8e9636333b06e
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/rt.rs:148:20
  29:     0x55fc98e91bee - std::rt::lang_start::h9cae520d3e6fd2c0
  30:     0x7fdbd6ac81ca - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  31:     0x7fdbd6ac828b - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  32:     0x55fc98e72d75 - _start
  33:                0x0 - <unknown>

martin-rueegg avatar May 31 '25 12:05 martin-rueegg