"Yu, Mingli" mingli.yu@windriver.com writes:
Program received signal SIGSEGV, Segmentation fault. nettle_sha256_update (ctx=0x7fffffffe5c0, length=<optimized out>, data=0x55559260 <error: Cannot access memory at address 0x55559260>) at ../nettle-3.4.1/sha256.c:99 99 ../nettle-3.4.1/sha256.c: No such file or directory. (gdb) bt #0 nettle_sha256_update (ctx=0x7fffffffe5c0, length=<optimized out>, data=0x55559260 <error: Cannot access memory at address 0x55559260>) at ../nettle-3.4.1/sha256.c:99 #1 0x00007ffff7fa9bb6 in nettle_pbkdf2 (mac_ctx=mac_ctx@entry=0x7fffffffe4e0, update=0x7ffff7fa7cb0 <nettle_hmac_sha256_update>, digest=0x7ffff7fa7cc0 <nettle_hmac_sha256_digest>, digest_size=digest_size@entry=32, iterations=iterations@entry=1, salt_length=salt_length@entry=4, salt=0x55559260 <error: Cannot access memory at address 0x55559260>, length=16, dst=0x55555555a290 "") at ../nettle-3.4.1/pbkdf2.c:78 #2 0x00007ffff7fa9dd3 in nettle_pbkdf2_hmac_sha256 ( key_length=<optimized out>, key=<optimized out>, iterations=1, salt_length=4, salt=0x55559260 <error: Cannot access memory at address 0x55559260>, length=16, dst=0x55555555a290 "") at ../nettle-3.4.1/pbkdf2-hmac-sha256.c:51 #3 0x000055555555544c in main (argc=<optimized out>, argv=<optimized out>) at ../../nettle-3.4.1/tools/nettle-pbkdf2.c:167
Not sure if everything here can be trusted, but the
salt=0x55559260 <error: Cannot access memory at address 0x55559260>,
in the backtrace indicates some problem with the salt passed down fron the nettle-pbkdf2 tool to the nettle library functions.
It's allocated as
salt = strdup (argv[0]);
at line 146 in tools/nettle-pbkdf2.c (after an argv += optind). I note that there's no check of the return value, but if strdup fails it should return NULL, which would be a different invalid address.
You may want to examine the values of those variables in the debugger or with debug printouts. E.g, try this patch.
--- a/tools/nettle-pbkdf2.c +++ b/tools/nettle-pbkdf2.c @@ -144,6 +144,11 @@ main (int argc, char **argv) }
salt = strdup (argv[0]); + if (!salt) + die ("strdup failed: Virtual memory exhausted.\n"); + fprintf(stderr, "argv[0]: '%s'\n", argv[0]); + fprintf(stderr, "copy (salt): '%s'\n", salt); + salt_length = strlen(argv[0]);
if (hex_salt)
What kind of machine, operating system, and compiler are you using? Since the testsuite passes on the test systems (including x86_64 and
I work on x86_64 and use gcc for compiler.
And operating system, please?
Regards, /Niels