diff options
Diffstat (limited to 'lib/erl_interface/src')
-rw-r--r-- | lib/erl_interface/src/Makefile.in | 34 | ||||
-rw-r--r-- | lib/erl_interface/src/connect/ei_resolve.c | 7 | ||||
-rw-r--r-- | lib/erl_interface/src/encode/encode_atom.c | 8 | ||||
-rw-r--r-- | lib/erl_interface/src/encode/encode_string.c | 8 | ||||
-rw-r--r-- | lib/erl_interface/src/epmd/epmd_port.c | 9 | ||||
-rw-r--r-- | lib/erl_interface/src/legacy/erl_connect.c | 5 | ||||
-rw-r--r-- | lib/erl_interface/src/legacy/erl_fix_alloc.c | 6 | ||||
-rw-r--r-- | lib/erl_interface/src/legacy/erl_timeout.c | 1 | ||||
-rw-r--r-- | lib/erl_interface/src/misc/ei_decode_term.c | 10 | ||||
-rw-r--r-- | lib/erl_interface/src/registry/reg_dump.c | 1 | ||||
-rw-r--r-- | lib/erl_interface/src/registry/reg_restore.c | 5 |
11 files changed, 42 insertions, 52 deletions
diff --git a/lib/erl_interface/src/Makefile.in b/lib/erl_interface/src/Makefile.in index 8ff142a366..0d841cfa48 100644 --- a/lib/erl_interface/src/Makefile.in +++ b/lib/erl_interface/src/Makefile.in @@ -143,7 +143,6 @@ BINDIR = $(ERL_TOP)/lib/erl_interface/bin/$(TARGET) vpath %.c connect:encode:decode:misc:epmd:legacy:registry - ########################################################################### # List targets ########################################################################### @@ -202,11 +201,6 @@ ifeq ($(USING_VC),yes) # Windows targets TARGETS = \ - $(BINDIR) \ - $(OBJDIR) \ - $(MT_OBJDIR) \ - $(MD_OBJDIR) \ - $(MDD_OBJDIR) \ $(OBJ_TARGETS) \ $(EXE_TARGETS) @@ -236,9 +230,6 @@ else ifeq ($USING_MINGW,yes) TARGETS = \ - $(BINDIR) \ - $(OBJDIR) \ - $(MD_OBJDIR) \ $(OBJ_TARGETS) \ $(EXE_TARGETS) @@ -257,10 +248,6 @@ else ifdef THR_DEFS TARGETS = \ - $(BINDIR) \ - $(OBJDIR) \ - $(ST_OBJDIR) \ - $(MT_OBJDIR) \ $(OBJ_TARGETS) \ $(EXE_TARGETS) @@ -283,9 +270,6 @@ FAKE_TARGETS = \ else TARGETS = \ - $(BINDIR) \ - $(OBJDIR) \ - $(ST_OBJDIR) \ $(OBJ_TARGETS) \ $(EXE_TARGETS) @@ -601,23 +585,7 @@ $(MDD_OBJDIR)/%.o: %.c # Create directories ########################################################################### -$(BINDIR): - mkdir -p $(BINDIR) - -$(OBJDIR): - mkdir -p $(OBJDIR) - -$(ST_OBJDIR): - mkdir -p $(ST_OBJDIR) - -$(MT_OBJDIR): - mkdir -p $(MT_OBJDIR) - -$(MD_OBJDIR): - mkdir -p $(MD_OBJDIR) - -$(MDD_OBJDIR): - mkdir -p $(MDD_OBJDIR) +_create_dirs := $(shell mkdir -p $(BINDIR) $(OBJDIR) $(ST_OBJDIR) $(MT_OBJDIR) $(MD_OBJDIR) $(MDD_OBJDIR)) ########################################################################### # Special rules diff --git a/lib/erl_interface/src/connect/ei_resolve.c b/lib/erl_interface/src/connect/ei_resolve.c index 50c5a4161d..ba8f8fbce3 100644 --- a/lib/erl_interface/src/connect/ei_resolve.c +++ b/lib/erl_interface/src/connect/ei_resolve.c @@ -185,7 +185,12 @@ static int verify_dns_configuration(void) * align: increment buf until it is dword-aligned, reduce len by same amount. * advance: increment buf by n bytes, reduce len by same amount . */ -#define align_buf(buf,len) for (;(((unsigned)buf)&0x3); (buf)++, len--) +#if defined SIZEOF_VOID_P +#define ALIGNBYTES (SIZEOF_VOID_P - 1) +#else +#define ALIGNBYTES (sizeof(void*) - 1) +#endif +#define align_buf(buf,len) for (;(((unsigned)buf) & ALIGNBYTES); (buf)++, len--) #define advance_buf(buf,len,n) ((buf)+=(n),(len)-=(n)) /* "and now the tricky part..." */ diff --git a/lib/erl_interface/src/encode/encode_atom.c b/lib/erl_interface/src/encode/encode_atom.c index 69f2d1451c..6f41f045e0 100644 --- a/lib/erl_interface/src/encode/encode_atom.c +++ b/lib/erl_interface/src/encode/encode_atom.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2009. All Rights Reserved. + * Copyright Ericsson AB 1998-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -17,13 +17,17 @@ * %CopyrightEnd% */ #include <string.h> +#include <limits.h> #include "eidef.h" #include "eiext.h" #include "putget.h" int ei_encode_atom(char *buf, int *index, const char *p) { - return ei_encode_atom_len(buf, index, p, strlen(p)); + size_t len = strlen(p); + + if (len >= INT_MAX) return -1; + return ei_encode_atom_len(buf, index, p, len); } int ei_encode_atom_len(char *buf, int *index, const char *p, int len) diff --git a/lib/erl_interface/src/encode/encode_string.c b/lib/erl_interface/src/encode/encode_string.c index 1d342cb605..d00d2f3e81 100644 --- a/lib/erl_interface/src/encode/encode_string.c +++ b/lib/erl_interface/src/encode/encode_string.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2009. All Rights Reserved. + * Copyright Ericsson AB 1998-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -17,6 +17,7 @@ * %CopyrightEnd% */ #include <string.h> +#include <limits.h> #include "eidef.h" #include "eiext.h" #include "putget.h" @@ -24,7 +25,10 @@ int ei_encode_string(char *buf, int *index, const char *p) { - return ei_encode_string_len(buf, index, p, strlen(p)); + size_t len = strlen(p); + + if (len >= INT_MAX) return -1; + return ei_encode_string_len(buf, index, p, len); } int ei_encode_string_len(char *buf, int *index, const char *p, int len) diff --git a/lib/erl_interface/src/epmd/epmd_port.c b/lib/erl_interface/src/epmd/epmd_port.c index 698c75c217..a433815eb7 100644 --- a/lib/erl_interface/src/epmd/epmd_port.c +++ b/lib/erl_interface/src/epmd/epmd_port.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2010. All Rights Reserved. + * Copyright Ericsson AB 1998-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -228,11 +228,8 @@ int ei_epmd_port (struct in_addr *addr, const char *alive, int *dist) return ei_epmd_port_tmo (addr, alive, dist, 0); } -int ei_epmd_port_tmo (struct in_addr *addr, const char *alive, int *dist, - unsigned ms) +int ei_epmd_port_tmo (struct in_addr *addr, const char *alive, int *dist, unsigned ms) { - int i; - - return ei_epmd_r4_port(addr,alive,dist,ms); + return ei_epmd_r4_port(addr,alive,dist,ms); } diff --git a/lib/erl_interface/src/legacy/erl_connect.c b/lib/erl_interface/src/legacy/erl_connect.c index fdf689e191..41d4fa3138 100644 --- a/lib/erl_interface/src/legacy/erl_connect.c +++ b/lib/erl_interface/src/legacy/erl_connect.c @@ -293,8 +293,13 @@ static int erl_do_receive_msg(int fd, ei_x_buff* x, ErlMessage* emsg) emsg->msg = NULL; if (msg.from.node[0] != '\0') emsg->from = erl_mk_pid(msg.from.node, msg.from.num, msg.from.serial, msg.from.creation); + else + emsg->from = NULL; if (msg.to.node[0] != '\0') emsg->to = erl_mk_pid(msg.to.node, msg.to.num, msg.to.serial, msg.to.creation); + else + emsg->to = NULL; + memcpy(emsg->to_name, msg.toname, MAXATOMLEN+1); return r; } diff --git a/lib/erl_interface/src/legacy/erl_fix_alloc.c b/lib/erl_interface/src/legacy/erl_fix_alloc.c index 20f3024e41..2ed0dd1470 100644 --- a/lib/erl_interface/src/legacy/erl_fix_alloc.c +++ b/lib/erl_interface/src/legacy/erl_fix_alloc.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. + * Copyright Ericsson AB 1996-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -109,6 +109,10 @@ void *erl_eterm_alloc (void) erl_eterm_state->freed--; } else if ((b = malloc(sizeof(*b))) == NULL) { erl_errno = ENOMEM; +#ifdef _REENTRANT + ei_mutex_unlock(erl_eterm_state->lock); +#endif /* _REENTRANT */ + return NULL; } erl_eterm_state->allocated++; b->free = 0; diff --git a/lib/erl_interface/src/legacy/erl_timeout.c b/lib/erl_interface/src/legacy/erl_timeout.c index d9560eebc8..146a106e7c 100644 --- a/lib/erl_interface/src/legacy/erl_timeout.c +++ b/lib/erl_interface/src/legacy/erl_timeout.c @@ -43,6 +43,7 @@ # endif #endif +#include "erl_interface.h" #include "erl_timeout.h" typedef struct jmp_s { diff --git a/lib/erl_interface/src/misc/ei_decode_term.c b/lib/erl_interface/src/misc/ei_decode_term.c index bfb4571337..0b82ef0e35 100644 --- a/lib/erl_interface/src/misc/ei_decode_term.c +++ b/lib/erl_interface/src/misc/ei_decode_term.c @@ -25,8 +25,8 @@ #include "ei_decode_term.h" #include "putget.h" -/* Returns 0 on successful encoding, -1 on error, and 1 if the term seems - alright, but does not fit in the term structure. If it returns 0, the +/* Returns 1 on successful encoding, -1 on error, and 0 if the term seems + alright, but does not fit in the term structure. If it returns 1, the index will be incremented, and the term contains the decoded term. */ int ei_decode_ei_term(const char* buf, int* index, ei_term* term) @@ -111,10 +111,10 @@ int ei_decode_ei_term(const char* buf, int* index, ei_term* term) break; case ERL_SMALL_TUPLE_EXT: term->arity = get8(s); - break; /*return 0;*/ + break; case ERL_LARGE_TUPLE_EXT: term->arity = get32be(s); - break; /*return 0;*/ + break; case ERL_NIL_EXT: term->arity = 0; break; @@ -123,7 +123,7 @@ int ei_decode_ei_term(const char* buf, int* index, ei_term* term) return 0; case ERL_LIST_EXT: term->arity = get32be(s); - break; /*return 0;*/ + break; case ERL_BINARY_EXT: term->size = get32be(s); return 0; diff --git a/lib/erl_interface/src/registry/reg_dump.c b/lib/erl_interface/src/registry/reg_dump.c index 1e640fb506..d2854c10b5 100644 --- a/lib/erl_interface/src/registry/reg_dump.c +++ b/lib/erl_interface/src/registry/reg_dump.c @@ -215,6 +215,7 @@ static int mn_send_write(int fd, erlang_pid *mnesia, const char *key, ei_reg_obj else ei_encode_long(msgbuf,&index,(long)(obj->val.p)); /* just the pointer */ break; default: + if (dbuf) free(dbuf); return -1; } diff --git a/lib/erl_interface/src/registry/reg_restore.c b/lib/erl_interface/src/registry/reg_restore.c index 765c3f4314..7bc1c758af 100644 --- a/lib/erl_interface/src/registry/reg_restore.c +++ b/lib/erl_interface/src/registry/reg_restore.c @@ -303,6 +303,9 @@ int ei_reg_restore(int fd, ei_reg *reg, const char *mntab) if (mn_decode_insert(reg,msgbuf,&index,keybuf)) goto restore_failure; } + if (keybuf) free(keybuf); + if (dbuf) free(dbuf); + /* wait for unlink */ if (mn_unlink(fd)) return -1; @@ -310,8 +313,6 @@ int ei_reg_restore(int fd, ei_reg *reg, const char *mntab) ei_hash_foreach(reg->tab,clean_obj); /* success */ - if (keybuf) free(keybuf); - if (dbuf) free(dbuf); return 0; restore_failure: |