mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Fix possible system freeze on Mac OS X.
This commit is contained in:
parent
98f10d74b8
commit
4fa261f8ec
14 changed files with 73 additions and 28 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-05-19 Werner Koch <wk@g10code.com>
|
||||
|
||||
* mischelp.h: Define PF_LOCAL, AF_LOCAL and SUN_LEN if requested.
|
||||
* logging.c (fun_writer): Use SUN_LEN to fix a Mac OS X freeze.
|
||||
|
||||
2009-03-25 Werner Koch <wk@g10code.com>
|
||||
|
||||
* logging.c (fun_closer): Never close fd 2.
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
|
||||
#define JNLIB_NEED_LOG_LOGV 1
|
||||
#define JNLIB_NEED_AFLOCAL 1
|
||||
#include "libjnlib-config.h"
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -152,8 +153,7 @@ fun_writer (void *cookie_arg, const char *buffer, my_funopen_hook_size_t size)
|
|||
addr.sun_family = PF_LOCAL;
|
||||
strncpy (addr.sun_path, cookie->name, sizeof (addr.sun_path)-1);
|
||||
addr.sun_path[sizeof (addr.sun_path)-1] = 0;
|
||||
addrlen = (offsetof (struct sockaddr_un, sun_path)
|
||||
+ strlen (addr.sun_path) + 1);
|
||||
addrlen = SUN_LEN (&addr);
|
||||
|
||||
if (connect (cookie->fd, (struct sockaddr *) &addr, addrlen) == -1)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* mischelp.h - Miscellaneous helper macros and functions
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003,
|
||||
* 2006, 2007 Free Software Foundation, Inc.
|
||||
* 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of JNLIB.
|
||||
*
|
||||
|
@ -60,5 +60,35 @@ time_t timegm (struct tm *tm);
|
|||
#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
|
||||
|
||||
|
||||
/* Include hacks which are mainly required for Slowaris. */
|
||||
#if defined(JNLIB_NEED_AFLOCAL) && !defined(HAVE_W32_SYSTEM)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifndef PF_LOCAL
|
||||
# ifdef PF_UNIX
|
||||
# define PF_LOCAL PF_UNIX
|
||||
# else
|
||||
# define PF_LOCAL AF_UNIX
|
||||
# endif
|
||||
#endif /*PF_LOCAL*/
|
||||
#ifndef AF_LOCAL
|
||||
# define AF_LOCAL AF_UNIX
|
||||
#endif /*AF_UNIX*/
|
||||
|
||||
/* We used to avoid this macro in GnuPG and inlined the AF_LOCAL name
|
||||
length computation directly with the little twist of adding 1 extra
|
||||
byte. It seems that this was needed once on an old HP/UX box and
|
||||
there are also rumours that 4.3 Reno and DEC systems need it. This
|
||||
one-off buglet did not harm any current system until it came to Mac
|
||||
OS X where the kernel (as of May 2009) exhibited a strange bug: The
|
||||
systems basically froze in the connect call if the passed name
|
||||
contained an invalid directory part. Ignore the old Unices. */
|
||||
#ifndef SUN_LEN
|
||||
# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
|
||||
+ strlen ((ptr)->sun_path))
|
||||
#endif /*SUN_LEN*/
|
||||
#endif /*JNLIB_NEED_AFLOCAL && !HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
#endif /*LIBJNLIB_MISCHELP_H*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue