You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
We need to rework join_url as it has several memory and security problems.
First we should replace all strdup and strcpy with strndup and strncpy and take '\0' into account. Then we have to fix all the valgrind errors I found (cleaned the OpenSSL stuff):
~/D/D/i/libidroplink >>> (master) valgrind a.out --leak-check-full --track-origins=yes
==42839== Memcheck, a memory error detector
==42839== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==42839== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==42839== Command: a.out --leak-check-full --track-origins=yes
==42839==
/* MachO stuff removed */
.F
check_api failed:
tests/libidroplink_tests.c:34: Incompatible remote detected.
==42839== Conditional jump or move depends on uninitialised value(s)
==42839== at 0x1000146C8: strlen (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x101587D3D: __strcat_chk (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100002B88: join_url (in ./a.out)
==42839== by 0x100001BB2: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid write of size 1
==42839== at 0x1017928C0: _platform_memmove$VARIANT$Nehalem (in /usr/lib/system/libsystem_platform.dylib)
==42839== by 0x101587D83: __strcat_chk (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100002B88: join_url (in ./a.out)
==42839== by 0x100001BB2: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b2d792 is 0 bytes after a block of size 34 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100001BB2: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid read of size 1
==42839== at 0x1000146C8: strlen (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x10155EB78: strdup (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10002CBA7: Curl_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003B99E: curl_easy_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100001BCA: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b2d792 is 0 bytes after a block of size 34 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100001BB2: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid read of size 1
==42839== at 0x1017928CA: _platform_memmove$VARIANT$Nehalem (in /usr/lib/system/libsystem_platform.dylib)
==42839== by 0x10155EB9E: strdup (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10002CBA7: Curl_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003B99E: curl_easy_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100001BCA: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b2d792 is 0 bytes after a block of size 34 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100001BB2: create_user (in ./a.out)
==42839== by 0x100008793: add_user (in ./a.out)
==42839== by 0x100007F77: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
.F
add_user failed:
tests/libidroplink_tests.c:41: Should have returned id
==42839== Conditional jump or move depends on uninitialised value(s)
==42839== at 0x1000146C8: strlen (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x101587D3D: __strcat_chk (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100002B88: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid write of size 8
==42839== at 0x1017928A7: _platform_memmove$VARIANT$Nehalem (in /usr/lib/system/libsystem_platform.dylib)
==42839== by 0x101587D83: __strcat_chk (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100002B88: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b43ade is 46 bytes inside a block of size 53 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid write of size 1
==42839== at 0x1017928C0: _platform_memmove$VARIANT$Nehalem (in /usr/lib/system/libsystem_platform.dylib)
==42839== by 0x101587D83: __strcat_chk (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100002B88: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b43ae6 is 1 bytes after a block of size 53 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid read of size 1
==42839== at 0x1000146BF: strlen (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x10155EB78: strdup (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10002CBA7: Curl_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003B99E: curl_easy_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100000FD2: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b43ae5 is 0 bytes after a block of size 53 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
==42839== Invalid read of size 1
==42839== at 0x1017928BA: _platform_memmove$VARIANT$Nehalem (in /usr/lib/system/libsystem_platform.dylib)
==42839== by 0x10155EB9E: strdup (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10002CBA7: Curl_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003B99E: curl_easy_setopt (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100000FD2: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839== Address 0x107b43ae8 is 3 bytes after a block of size 53 alloc'd
==42839== at 0x100012EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==42839== by 0x100002B5C: join_url (in ./a.out)
==42839== by 0x100000FBA: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
==42839== Use of uninitialised value of size 8
==42839== at 0x10154E044: __svfscanf_l (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x101556E14: vsscanf_l (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10154705A: sscanf (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100030A9F: create_conn (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003054E: Curl_connect (in /usr/lib/libcurl.4.dylib)
==42839== by 0x1000428D1: multi_runsingle (in /usr/lib/libcurl.4.dylib)
==42839== by 0x1000426E1: curl_multi_perform (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003BB13: curl_easy_perform (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100001066: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
/* OpenSSL removed */
==42839==
==42839== Use of uninitialised value of size 8
==42839== at 0x10154E044: __svfscanf_l (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x101556E14: vsscanf_l (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x10154705A: sscanf (in /usr/lib/system/libsystem_c.dylib)
==42839== by 0x100030FBA: create_conn (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003054E: Curl_connect (in /usr/lib/libcurl.4.dylib)
==42839== by 0x1000428D1: multi_runsingle (in /usr/lib/libcurl.4.dylib)
==42839== by 0x1000426E1: curl_multi_perform (in /usr/lib/libcurl.4.dylib)
==42839== by 0x10003BB13: curl_easy_perform (in /usr/lib/libcurl.4.dylib)
==42839== by 0x100001066: get_id_for_email (in ./a.out)
==42839== by 0x10000893E: fetch_id_for_mail (in ./a.out)
==42839== by 0x10000807B: test_suite (in ./a.out)
==42839== by 0x100007D4A: main (in ./a.out)
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
==42839==
/* OpenSSL removed */
.F
fetch_id_for_mail failed:
tests/libidroplink_tests.c:52: Should have returned id
.F
get_token failed:
tests/libidroplink_tests.c:71: Should have returned token
.F
fetch_user failed:
tests/libidroplink_tests.c:80: Should have returned a user struct
.F
log_out failed:
tests/libidroplink_tests.c:102: Should have logged the user out
..F
remove_user failed:
tests/libidroplink_tests.c:114: Should have returned another token
7 tests, 15 assertions, 7 failures
Finished in 1.21745876 seconds (real) 0.71342100 seconds (proc)
==42839==
==42839== HEAP SUMMARY:
==42839== in use at exit: 424,713 bytes in 906 blocks
==42839== total heap usage: 1,923 allocs, 1,017 frees, 977,145 bytes allocated
==42839==
==42839== LEAK SUMMARY:
==42839== definitely lost: 4,081 bytes in 41 blocks
==42839== indirectly lost: 6,404 bytes in 34 blocks
==42839== possibly lost: 5,280 bytes in 129 blocks
==42839== still reachable: 37,942 bytes in 393 blocks
==42839== suppressed: 371,006 bytes in 309 blocks
==42839== Rerun with --leak-check=full to see details of leaked memory
==42839==
==42839== For counts of detected and suppressed errors, rerun with: -v
==42839== Use --track-origins=yes to see where uninitialised values come from
==42839== ERROR SUMMARY: 96 errors from 47 contexts (suppressed: 0 from 0)
The text was updated successfully, but these errors were encountered:
We need to rework join_url as it has several memory and security problems.
First we should replace all
strdup
andstrcpy
withstrndup
andstrncpy
and take'\0'
into account. Then we have to fix all the valgrind errors I found (cleaned the OpenSSL stuff):The text was updated successfully, but these errors were encountered: