Hi,

lftp-3.2.0 won't compile out of the box on Slackware 10.1:

$ ./configure --prefix=/usr/local --enable-shared --enable-static
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
[...]
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
$ make
Making all in include
make[1]: Entering directory `/usr/local/src/lftp-3.2.0/include'
[...]
if /bin/sh ../libtool --silent --tag=CXX --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -O2 -Wall -Wwrite-strings -Woverloaded-virtual -fno-exceptions -fno-rtti -fno-implement-inlines -Winline -MT lftp_ssl.lo -MD -MP -MF ".deps/lftp_ssl.Tpo" -c -o lftp_ssl.lo lftp_ssl.cc; \
then mv -f ".deps/lftp_ssl.Tpo" ".deps/lftp_ssl.Plo"; else rm -f ".deps/lftp_ssl.Tpo"; exit 1; fi
lftp_ssl.cc: In member function `virtual void lftp_ssl_gnutls_instance::Reconfig(const char*)':
lftp_ssl.cc:167: error: jump to label `crl'
lftp_ssl.cc:143: error: from here
lftp_ssl.cc:144: error: crosses initialization of `const char*ca_file'
lftp_ssl.cc:187: error: jump to label `end'
lftp_ssl.cc:169: error: from here
lftp_ssl.cc:170: error: crosses initialization of `const char*crl_file'
make[1]: *** [lftp_ssl.lo] Error 1
make[1]: Leaving directory `/usr/local/src/lftp-3.2.0/src'
make: *** [all-recursive] Error 1
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/specs
Configured with: ../gcc-3.3.4/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.3.4


The enclosed patch fixes the problem by getting rid of the goto statements.
I still left the labels intact (resulting in two gcc warnings about defined
but unused labels), so it's easier to verify whether the program flow is
still correct (it should be, AFAICT).

Thomas

PS: Please cc: me on replies, as I'm not subscribed to this list - thanks!
--
=-------------------------------------------------------------------------=
- Thomas "ZlatkO" Zajic <[EMAIL PROTECTED]>  Linux-2.4.30 & Thunderbird-1.0.2 -
-  "It is not easy to cut through a human head with a hacksaw."  (M. C.)  -
=-------------------------------------------------------------------------=

diff -ur lftp-3.2.0/src/lftp_ssl.cc lftp-3.2.0-fixed/src/lftp_ssl.cc
--- lftp-3.2.0/src/lftp_ssl.cc	2005-05-13 15:46:04.000000000 +0200
+++ lftp-3.2.0-fixed/src/lftp_ssl.cc	2005-05-18 09:07:09.000000000 +0200
@@ -139,43 +139,44 @@
    crl_list_size=0;
 
    // load CA
-   if(name && strcmp(name,"ssl:ca-file"))
-      goto crl;
-   const char *ca_file=ResMgr::Query("ssl:ca-file",0);
-   if(!ca_file || !ca_file[0])
-      goto crl;
-
-   gnutls_datum_t ca_pem=mmap_file(ca_file);
-   if(!ca_pem.data)
+   if(!(name && strcmp(name,"ssl:ca-file")))
    {
-      Log::global->Format(0,"%s: %s\n",ca_file,strerror(errno));
-      goto crl;
-   }
-
-   ca_list_size=64;
-   ca_list=(gnutls_x509_crt_t*)xmalloc(ca_list_size*sizeof(gnutls_x509_crl_t));
-   res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED);
-   if(res==GNUTLS_E_SHORT_MEMORY_BUFFER)
-   {
-      ca_list=(gnutls_x509_crt_t*)xrealloc(ca_list,ca_list_size*sizeof(gnutls_x509_crl_t));
-      res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,0);
-   }
-   if(res<0)
-      Log::global->Format(0,"gnutls_x509_crt_list_import: %s\n",gnutls_strerror(res));
-   munmap_file(ca_pem);
-
+      const char *ca_file=ResMgr::Query("ssl:ca-file",0);
+      if(!(!ca_file || !ca_file[0]))
+      {
+          gnutls_datum_t ca_pem=mmap_file(ca_file);
+	  if(!ca_pem.data)
+          {
+              Log::global->Format(0,"%s: %s\n",ca_file,strerror(errno));
+          }
+	  else
+	  {
+	     ca_list_size=64;
+	     ca_list=(gnutls_x509_crt_t*)xmalloc(ca_list_size*sizeof(gnutls_x509_crl_t));
+	     res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED);
+	     if(res==GNUTLS_E_SHORT_MEMORY_BUFFER)
+             {
+	        ca_list=(gnutls_x509_crt_t*)xrealloc(ca_list,ca_list_size*sizeof(gnutls_x509_crl_t));
+		res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,0);
+	     }
+	     if(res<0)
+	        Log::global->Format(0,"gnutls_x509_crt_list_import: %s\n",gnutls_strerror(res));
+	     munmap_file(ca_pem);
+          }
+       }
+    }
 crl:
    if(name && strcmp(name,"ssl:crl-file"))
-      goto end;
+      return;
    const char *crl_file=ResMgr::Query("ssl:crl-file",0);
    if(!crl_file || !crl_file[0])
-      goto end;
+      return;
 
    gnutls_datum_t crl_pem=mmap_file(crl_file);
    if(!crl_pem.data)
    {
       Log::global->Format(0,"%s: %s\n",crl_file,strerror(errno));
-      goto end;
+      return;
    }
    crl_list_size=1;
    crl_list=(gnutls_x509_crl_t*)xmalloc(crl_list_size*sizeof(gnutls_x509_crl_t));

Reply via email to