Revision: 4922 http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4922&view=rev Author: ossman_ Date: 2012-07-03 14:52:26 +0000 (Tue, 03 Jul 2012) Log Message: ----------- GnuTLS 3.x has removed gnutls_transport_set_global_errno() in favour of gnutls_transport_set_errno(). Make sure we call the right errno function depending on which GnuTLS we're using.
Modified Paths: -------------- trunk/CMakeLists.txt trunk/common/rdr/TLSInStream.cxx trunk/common/rdr/TLSOutStream.cxx trunk/config.h.in Added Paths: ----------- trunk/common/rdr/TLSErrno.h Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2012-07-03 14:43:38 UTC (rev 4921) +++ trunk/CMakeLists.txt 2012-07-03 14:52:26 UTC (rev 4922) @@ -356,7 +356,8 @@ # system's version (if available) to perform this test. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz) endif() - check_function_exists(gnutls_transport_set_global_errno HAVE_OLD_GNUTLS) + check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO) + check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO) check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT) check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T) check_type_size(gnutls_datum_t GNUTLS_DATUM_T) Added: trunk/common/rdr/TLSErrno.h =================================================================== --- trunk/common/rdr/TLSErrno.h (rev 0) +++ trunk/common/rdr/TLSErrno.h 2012-07-03 14:52:26 UTC (rev 4922) @@ -0,0 +1,46 @@ +/* Copyright (C) 2012 Pierre Ossman for Cendio AB + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#ifndef __RDR_TLSERRNO_H__ +#define __RDR_TLSERRNO_H__ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_GNUTLS + +#include <errno.h> + +namespace rdr { + + static inline void gnutls_errno_helper(gnutls_session session, int _errno) + { +#if defined(HAVE_GNUTLS_SET_ERRNO) + gnutls_transport_set_errno(session, _errno); +#elif defined(HAVE_GNUTLS_SET_GLOBAL_ERRNO) + gnutls_transport_set_global_errno(_errno); +#else + errno = _errno; +#endif + } +}; + +#endif + +#endif Modified: trunk/common/rdr/TLSInStream.cxx =================================================================== --- trunk/common/rdr/TLSInStream.cxx 2012-07-03 14:43:38 UTC (rev 4921) +++ trunk/common/rdr/TLSInStream.cxx 2012-07-03 14:52:26 UTC (rev 4922) @@ -25,12 +25,9 @@ #include <rdr/Exception.h> #include <rdr/TLSException.h> #include <rdr/TLSInStream.h> +#include <rdr/TLSErrno.h> #include <errno.h> -#ifdef HAVE_OLD_GNUTLS -#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0) -#endif - #ifdef HAVE_GNUTLS using namespace rdr; @@ -43,7 +40,7 @@ try { if (!in->check(1, 1, false)) { - gnutls_transport_set_global_errno(EAGAIN); + gnutls_errno_helper(self->session, EAGAIN); return -1; } @@ -53,7 +50,7 @@ in->readBytes(data, size); } catch (Exception& e) { - gnutls_transport_set_global_errno(EINVAL); + gnutls_errno_helper(self->session, EINVAL); return -1; } Modified: trunk/common/rdr/TLSOutStream.cxx =================================================================== --- trunk/common/rdr/TLSOutStream.cxx 2012-07-03 14:43:38 UTC (rev 4921) +++ trunk/common/rdr/TLSOutStream.cxx 2012-07-03 14:52:26 UTC (rev 4922) @@ -25,12 +25,9 @@ #include <rdr/Exception.h> #include <rdr/TLSException.h> #include <rdr/TLSOutStream.h> +#include <rdr/TLSErrno.h> #include <errno.h> -#ifdef HAVE_OLD_GNUTLS -#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0) -#endif - #ifdef HAVE_GNUTLS using namespace rdr; @@ -46,7 +43,7 @@ out->writeBytes(data, size); out->flush(); } catch (Exception& e) { - gnutls_transport_set_global_errno(EINVAL); + gnutls_errno_helper(self->session, EINVAL); return -1; } Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2012-07-03 14:43:38 UTC (rev 4921) +++ trunk/config.h.in 2012-07-03 14:52:26 UTC (rev 4922) @@ -8,7 +8,8 @@ #cmakedefine HAVE_STRCASECMP #cmakedefine HAVE_STRNCASECMP #cmakedefine HAVE_VSNPRINTF -#cmakedefine HAVE_OLD_GNUTLS +#cmakedefine HAVE_GNUTLS_SET_GLOBAL_ERRNO +#cmakedefine HAVE_GNUTLS_SET_ERRNO #cmakedefine HAVE_GNUTLS_X509_CRT_PRINT #cmakedefine HAVE_GNUTLS_X509_CRT_T #cmakedefine HAVE_GNUTLS_DATUM_T This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Tigervnc-commits mailing list Tigervnc-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-commits