mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-05 10:39:10 +00:00
fix named socket path generation for iOS to keep under BSD socket name length
This commit is contained in:
parent
08554b2655
commit
c5c82f822f
10
socket.c
10
socket.c
@ -24,6 +24,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
@ -53,7 +57,13 @@ int _make_local_sockaddr(struct __sourceloc __whence, struct socket_address *add
|
|||||||
addr->local.sun_family = AF_UNIX;
|
addr->local.sun_family = AF_UNIX;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
#ifdef TARGET_OS_IPHONE
|
||||||
|
// Do what we need to make the path short enough to fit in the BSD named socket maximum length of
|
||||||
|
// 104 chars, even if we have a horribly long container path name.
|
||||||
|
int r = snprintf(addr->local.sun_path,100,"%s/%s", getenv("HOME")?getenv("HOME"):"/tmp",fmt);
|
||||||
|
#else
|
||||||
int r = VFORMF_SERVAL_RUN_PATH(addr->local.sun_path, fmt, ap);
|
int r = VFORMF_SERVAL_RUN_PATH(addr->local.sun_path, fmt, ap);
|
||||||
|
#endif
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (!r)
|
if (!r)
|
||||||
return WHY("socket name overflow");
|
return WHY("socket name overflow");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user