Package: crywrap Version: 0.2.1-4.2 Severity: important Debian Etch:
# gdb ./src/crywrap GNU gdb 6.4.90-debian (gdb) run -d127.0.0.1/imap2 -l192.168.2.1/imaps -P/var/run/crywrap/crywrap-0.pid -pcert=/etc/crywrap/server.pem,key=/etc/crywrap/server.pem -u130 Starting program: /tmp/crywrap-0.2.1/src/crywrap -d 127.0.0.1/imap2 -l /imaps -P /var/run/crywrap/crywrap-0.pid -p cert=/etc/crywrap/server.pem,key=/etc/crywrap/server.pem -u 130 Failed to read a valid object file image from memory. Program received signal SIGSEGV, Segmentation fault. 0x0804b36d in _crywrap_config_parse_opt (key=112, arg=0xbf9ffb11 "cert=/etc/crywrap/server.pem,key=/etc/crywrap/server.pem", state=0xbf9fd598) at crywrap.c:355 355 while (*subopts != '\0') (gdb) bt full #0 0x0804b36d in _crywrap_config_parse_opt (key=112, arg=0xbf9ffb11 "cert=/etc/crywrap/server.pem,key=/etc/crywrap/server.pem", state=0xbf9fd598) at crywrap.c:355 cfg = <value optimized out> pem_cert = 0x0 pem_key = 0x0 subopts = 0x0 value = 0x806ad94 "wœ\004\b\001" #1 0xb7e4eaa6 in argp_parse () from /lib/tls/libc.so.6 No symbol table info available. #2 0x0804a8c3 in main (argc=7, argv=0xbf9fdb94, envp=0xbf9fdbb4) at crywrap.c:435 config = (crywrap_config_t *) 0x806acc8 server_socket = <value optimized out> Relates to "-p" argument: Value optarg is undefined (0) and not tested in the while() expression. Maybe, it should be arg? Proposed patch (please verify): ######################################### --- src/crywrap.c 15 Apr 2007 18:53:09 -0000 1.1.1.1 +++ src/crywrap.c 15 Apr 2007 20:02:57 -0000 @@ -349,10 +349,11 @@ cfg->pidfile = NULL; break; case 'p': - subopts = optarg; + subopts = arg; pem_cert = NULL; pem_key = NULL; - while (*subopts != '\0') + while ((arg) && (*subopts != '\0')) + { switch (bhc_getsubopt (&subopts, _crywrap_p_subopts, &value)) { case CRYWRAP_P_SUBOPT_CERT: @@ -365,6 +366,7 @@ pem_cert = bhc_strdup (value); break; } + } if (!pem_key) pem_key = bhc_strdup (pem_cert); if (!pem_cert) ######################################### Additional, unrelated patch suggestions (please verify against the compiler warnings and intended behaviour): ######################################### --- Mk/Rules.mk.in 15 Apr 2007 18:53:09 -0000 1.1.1.1 +++ Mk/Rules.mk.in 15 Apr 2007 20:10:29 -0000 @@ -105,6 +105,7 @@ -Wbad-function-cast -Wchar-subscripts -Wcomment -Wformat \ -Wformat-nonliteral -Wformat-security -Wimplicit \ -Wmissing-braces -Wparentheses -Wswitch -Wunused \ + -Wall -Werror -pedantic -std=c99 \ @WFLAGS_29X@ @WFLAGS_3X@ WFLAGS_29X = -Wsign-compare -Wmain -Wreturn-type WFLAGS_3X = -Wsequence-point -Wdiv-by-zero -W -Wno-unused-parameter @@ -456,7 +458,7 @@ _crywrap_session_cert_select (gnutls_session session, gnutls_datum *server_certs, int ncerts) { - int idx, data_length = 0, name_type, i; + unsigned int idx, data_length = 0, name_type, i; char *name; /* If we only have one cert, return that. */ @@ -509,7 +511,7 @@ static gnutls_session _crywrap_tls_session_create (const crywrap_config_t *config) { - gnutls_session session; + gnutls_session_t session; const int comp_prio[] = { GNUTLS_COMP_ZLIB, GNUTLS_COMP_LZO, GNUTLS_COMP_NULL, 0 }; const int mac_prio[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 }; @@ -539,7 +541,7 @@ gnutls_handshake_set_private_extensions (session, 1); gnutls_certificate_server_set_retrieve_function - (session, (gnutls_certificate_server_retrieve_function *) + ((gnutls_certificate_credentials_t) session, (gnutls_certificate_server_retrieve_function *) _crywrap_session_cert_select); if (config->verify) @@ -912,7 +914,7 @@ char buffer[_CRYWRAP_MAXBUF + 2]; fd_set fdset; struct sockaddr_storage faddr; - socklen_t socklen = sizeof (struct sockaddr_storage); + unsigned socklen_t socklen = sizeof (struct sockaddr_storage); char peer_name[NI_MAXHOST]; /* Log the connection */ ######################################### Additional hint: ./configure does not rely on libidn11-dev, needed to build the package Thanks for providing support, Hans-Jürgen