]> jfr.im git - irc/atheme/libmowgli-2.git/log
irc/atheme/libmowgli-2.git
2 years agopatricia: add a mowgli_patricia_clear() function master origin/HEAD origin/master
Aaron Jones [Mon, 28 Feb 2022 23:25:28 +0000 (23:25 +0000)] 
patricia: add a mowgli_patricia_clear() function

This does the same as mowgli_patricia_destroy(), but without actually
destroying the trie itself. Useful when you need to clear all of the
elements in a trie without losing the trie too.

You cannot always use MOWGLI_PATRICIA_FOREACH to do this, as it
returns the items on each iteration, not their key. If the item
doesn't contain the key, this is not useful.

Redefine mowgli_patricia_destroy() in terms of the new function.

2 years agoMerge pull request #52 from loongson-zjl/fix-machine-add-loongarch
alyx [Sun, 13 Jun 2021 02:15:25 +0000 (21:15 -0500)] 
Merge pull request #52 from loongson-zjl/fix-machine-add-loongarch

use __loongarch64 only

2 years agouse __loongarch64 only
zhangjialing [Mon, 7 Jun 2021 06:30:28 +0000 (14:30 +0800)] 
use __loongarch64 only

Signed-off-by: zhangjialing <redacted>
2 years agoMerge pull request #51 from loongson-zjl/fix-machine-add-loongarch
alyx [Fri, 4 Jun 2021 03:19:43 +0000 (22:19 -0500)] 
Merge pull request #51 from loongson-zjl/fix-machine-add-loongarch

Fix machine add loongarch

2 years agoMerge branch 'atheme:master' into fix-machine-add-loongarch
loongson-zjl [Fri, 4 Jun 2021 02:21:01 +0000 (10:21 +0800)] 
Merge branch 'atheme:master' into fix-machine-add-loongarch

2 years agoMerge pull request #50 from loongson-zjl/gnu-config-add-loongarch-support
alyx [Thu, 3 Jun 2021 17:31:55 +0000 (12:31 -0500)] 
Merge pull request #50 from loongson-zjl/gnu-config-add-loongarch-support

add loongarch support , the upstream gnu config has supported now

2 years agofix platform/machine.h add loongarch support
zhangjialing [Thu, 3 Jun 2021 08:59:42 +0000 (16:59 +0800)] 
fix platform/machine.h add loongarch support

2 years agoadd loongarch support , the upstream gnu config has supported now
zhangjialing [Thu, 3 Jun 2021 08:51:43 +0000 (16:51 +0800)] 
add loongarch support , the upstream gnu config has supported now

Signed-off-by: zhangjialing <redacted>
3 years agosrc/libmowgli/platform/Makefile: remove autoconf.h on distclean
Aaron Jones [Tue, 2 Mar 2021 06:09:12 +0000 (06:09 +0000)] 
src/libmowgli/platform/Makefile: remove autoconf.h on distclean

3 years agocore/heap.disabled: rip out HEAP_DEBUG code
Nicole Kleinhoff [Tue, 23 Feb 2021 00:34:16 +0000 (00:34 +0000)] 
core/heap.disabled: rip out HEAP_DEBUG code

There's little point in basically just reporting the equivalent of
malloc()/free() each time it happens; there isn't really anything to
debug here.

This also fixes a bug introduced in 101e46d8ac; the HEAP_DEBUG code had
not been properly adjusted and still referenced a variable removed in
that commit, thus breaking compilation with HEAP_DEBUG enabled.

3 years agocore/heap.disabled: remove tracking of allocations
Nicole Kleinhoff [Mon, 22 Feb 2021 23:30:45 +0000 (23:30 +0000)] 
core/heap.disabled: remove tracking of allocations

We used to keep track of allocated pointers to warn about them if the
heap was destroyed without all pointers being freed first. However, this
means we keep a list of pointers around until the heap is destroyed,
which for certain heaps may never happen; this will cause tools such as
Valgrind or LeakSanitizer to (correctly) see a valid pointer remaining
to the allocated memory and thus not detect a leak, even if any actual
*useful* pointers were lost.

These tools are more general and can also provide backtraces indicating
where the leaked memory was allocated, hence are strictly superior to
the check we did in mowgli_heap_destroy. Removing the remaining
bookkeeping allows them to work on mowgli_heap-allocated memory.

This essentially turns mowgli_heap_t and the related functions into a
wrapper around the configured allocate/deallocate functions except
always passing a fixed size. Since this is the code used when users
specifically requested to build without the heap allocator, that seems
like it shouldn't violate any assumptions.

3 years agoeventloop: delay freeing pollables until the current iteration finishes
Nicole Kleinhoff [Mon, 22 Feb 2021 22:56:32 +0000 (22:56 +0000)] 
eventloop: delay freeing pollables until the current iteration finishes

mowgli_pollable_destroy would free the pollable, however if called from
within a handler function invoked by the event loop, the event loop
might still have a pointer to it waiting to be processed, causing a
use-after-free.

Instead, keep track of whether we are currently processing events (i.e.
calling a pollops function that will process events); if we are doing
so, mark the pollable as removed and add it to a list of to-be-freed
pollables.

Individual implementations check the removed flag and ignore pollables
with it set; the general-case abstraction is responsible for keeping
track of whether we are currently in an event processing function and
cleaning up the list of pollables after each iteration.

For users of libmowgli, there is no change to API nor ABI as long as
programs use mowgli_{eventloop,pollable}_create to allocate the involved
structures.

3 years agoUse host tools for 'ar' and 'ranlib'
Wade Cline [Sun, 31 May 2020 21:19:00 +0000 (14:19 -0700)] 
Use host tools for 'ar' and 'ranlib'

Closes #49

4 years agoUpdate config.guess and config.sub
Aaron Jones [Fri, 3 Jan 2020 10:13:39 +0000 (10:13 +0000)] 
Update config.guess and config.sub

cf. https://github.com/atheme/libmowgli-2/issues/39

4 years agoMerge pull request #44 from awilfox/master
Alyx [Wed, 5 Jun 2019 06:19:21 +0000 (01:19 -0500)] 
Merge pull request #44 from awilfox/master

cacheline: Ensure sysconf var is defined before use on Linux

5 years agoSun Studio CC supports this, let it exist
Alyx [Sun, 5 May 2019 18:26:11 +0000 (13:26 -0500)] 
Sun Studio CC supports this, let it exist

Closes #47

5 years agomodule/interface: avoid %d/%u sign confusion
Aaron Jones [Fri, 5 Apr 2019 00:55:04 +0000 (00:55 +0000)] 
module/interface: avoid %d/%u sign confusion

5 years agolinebuf: avoid %d/%u sign confusion
Aaron Jones [Fri, 5 Apr 2019 00:54:52 +0000 (00:54 +0000)] 
linebuf: avoid %d/%u sign confusion

5 years agodns/evloop_reslib: avoid %d/%u sign confusion
Aaron Jones [Fri, 5 Apr 2019 00:54:41 +0000 (00:54 +0000)] 
dns/evloop_reslib: avoid %d/%u sign confusion

5 years agocontainer/patricia: avoid %d/%u sign confusion
Aaron Jones [Fri, 5 Apr 2019 00:54:25 +0000 (00:54 +0000)] 
container/patricia: avoid %d/%u sign confusion

5 years agocontainer/dictionary: avoid %d/%u sign confusion
Aaron Jones [Fri, 5 Apr 2019 00:54:11 +0000 (00:54 +0000)] 
container/dictionary: avoid %d/%u sign confusion

5 years agocontainer/patricia: mowgli_patricia_elem_find(): avoid potential UB
Aaron Jones [Sun, 24 Mar 2019 11:23:11 +0000 (11:23 +0000)] 
container/patricia: mowgli_patricia_elem_find(): avoid potential UB

Identified by Clang v9 UBSAN (-fsanitize=undefined):

    patricia.c:671:17: runtime error: member access within null
                       pointer of type 'union patricia_elem'

5 years agocore/heap.enabled: use size_t consistently
Aaron Jones [Mon, 21 Jan 2019 10:37:57 +0000 (10:37 +0000)] 
core/heap.enabled: use size_t consistently

The previous code was using `unsigned int'. This could be truncated on
a 64-bit system with many allocations.

Fortunately this implementation is entirely internal, and so changing
the data type does not break the ABI; the function declarations were
already using the correct type.

5 years agocore/heap.enabled: do commits 1a7a27f396dc95746050 & 686b66cd30b401baea5c
Aaron Jones [Mon, 21 Jan 2019 10:10:25 +0000 (10:10 +0000)] 
core/heap.enabled: do commits 1a7a27f396dc95746050 & 686b66cd30b401baea5c

5 years agocore/heap.disabled: add more debugging statements
Aaron Jones [Mon, 21 Jan 2019 09:17:37 +0000 (09:17 +0000)] 
core/heap.disabled: add more debugging statements

5 years agocore/heap.disabled: invoke underlying allocator directly
Aaron Jones [Mon, 21 Jan 2019 07:51:10 +0000 (07:51 +0000)] 
core/heap.disabled: invoke underlying allocator directly

The heap object stores its allocator for its entire lifetime, so
there's no need to call mowgli_alloc()/mowgli_free(), which also
stores the allocator tag behind the returned pointer.

This will (sometimes) reduce the memory consumption of every
allocation by a pointer and is slightly more efficient.

Also add some debugging assertions to validate the integrity of
the given/chosen allocator.

5 years agoBuild System & core/heap: add method to disable heap allocator
Aaron Jones [Sun, 20 Jan 2019 17:38:44 +0000 (17:38 +0000)] 
Build System & core/heap: add method to disable heap allocator

The heap allocator was found to be hiding a use-after-free error
in an unrelated program (not Atheme IRC Services).

Add a configure option to make mowgli.heap just wrap around
mowgli.alloc directly. This allows hardened memory allocators to
be plugged into the latter, which affect all individual object
allocations made by the former.

The disabled implementation also features more debug logging.

5 years agocore/heap: fix allocator logic
Aaron Jones [Sun, 20 Jan 2019 12:53:46 +0000 (12:53 +0000)] 
core/heap: fix allocator logic

- When given an allocator, use that for the heap itself and
  unconditionally for its blocks

- When not given an allocator, use mowgli's current allocator
  to allocate the heap object, and use mmap/VirtualAlloc for
  the blocks

- Consistently use the correct set of macro tests for the
  mmap/VirtualAlloc logic

5 years agocore/alloc: add function to retrieve current allocator
Aaron Jones [Sun, 20 Jan 2019 12:01:47 +0000 (12:01 +0000)] 
core/alloc: add function to retrieve current allocator

5 years agosrc/libmowgli/: mowgli_alloc(): tidy up various invocations
Aaron Jones [Fri, 18 Jan 2019 06:38:30 +0000 (06:38 +0000)] 
src/libmowgli/: mowgli_alloc(): tidy up various invocations

- (void *) can be implicitly converted to any other pointer type

  This includes (char *), (char **), and (const char ********)

  So remove the casts on the result.

- Avoid using type names in the parameter.

  The following 2 lines are equivalent:

  mowgli_foo_t *bar = (mowgli_foo_t *) mowgli_alloc(sizeof(mowgli_foo_t));
  mowgli_foo_t *bar = mowgli_alloc(sizeof *bar);

  The latter is easier to read, and if the type name of the
  variable is changed in the future, the type name inside the
  parameter does not need to be changed too.

  Also, sizeof is not a function, so it doesn't need parentheses
  when used in this manner. It did previously because the type name
  contained spaces (e.g. "struct mowgli_foo"), but we're using the
  variable name now, which can't contain spaces.

5 years agocore/alloc.c, core/allocator.c: fix calloc(3) and free(3) usage
Aaron Jones [Fri, 18 Jan 2019 04:22:15 +0000 (04:22 +0000)] 
core/alloc.c, core/allocator.c: fix calloc(3) and free(3) usage

calloc(3)'s 2 arguments are, in order: number of members, size of member.
-> Swap the arguments to the correct order.

free(3) is well-documented to do nothing when passed NULL.
-> Remove conditional check for non-NULL.

Also add malloc and alloc_size function attributes where necessary.

5 years agoext/getopt_long.c: rename and fix problematic macro
Aaron Jones [Fri, 18 Jan 2019 03:51:57 +0000 (03:51 +0000)] 
ext/getopt_long.c: rename and fix problematic macro

Non-system-defined macro names may not begin with 2 underscores,
or an underscore followed by a capital letter.

A pointer is not guaranteed to be representable in `unsigned long'.
Use `uintptr_t' from <stdint.h> instead.

Fixes compiler diagnostic:

getopt_long.c:41:9: warning: macro name is a reserved identifier
    [-Wreserved-id-macro]

5 years agothread/*_mutexops.c: fix missing extern pollops declarations#
Aaron Jones [Fri, 18 Jan 2019 03:47:02 +0000 (03:47 +0000)] 
thread/*_mutexops.c: fix missing extern pollops declarations#

Fixes compiler diagnostics:

null_mutexops.c:56:26: warning: no previous extern declaration for
    non-static variable '_mowgli_null_mutex_ops'
    [-Wmissing-variable-declarations]

posix_mutexops.c:69:26: warning: no previous extern declaration for
    non-static variable '_mowgli_posix_mutex_ops'
    [-Wmissing-variable-declarations]

... and probably others.

5 years agoplatform/cacheline.c: mark compilation-unit private variables static
Aaron Jones [Fri, 18 Jan 2019 03:42:39 +0000 (03:42 +0000)] 
platform/cacheline.c: mark compilation-unit private variables static

Fixes compiler diagnostic:

cacheline.c:31:8: warning: no previous extern declaration for
    non-static variable 'cacheline_size'
    [-Wmissing-variable-declarations]

5 years agoeventloop/*_pollops.c: fix missing extern pollops declarations
Aaron Jones [Fri, 18 Jan 2019 03:38:49 +0000 (03:38 +0000)] 
eventloop/*_pollops.c: fix missing extern pollops declarations

Fixes compiler diagnostics:

null_pollops.c:122:24: warning: no previous extern declaration for
    non-static variable '_mowgli_null_pollops'
    [-Wmissing-variable-declarations]

poll_pollops.c:229:24: warning: no previous extern declaration for
    non-static variable '_mowgli_poll_pollops'
    [-Wmissing-variable-declarations]

epoll_pollops.c:197:24: warning: no previous extern declaration for
    non-static variable '_mowgli_epoll_pollops'
    [-Wmissing-variable-declarations]

select_pollops.c:199:24: warning: no previous extern declaration for
    non-static variable '_mowgli_select_pollops'
    [-Wmissing-variable-declarations]

... and probably others.

5 years agocontainer/patricia.c: fix abuse of comma syntax
Aaron Jones [Fri, 18 Jan 2019 03:29:41 +0000 (03:29 +0000)] 
container/patricia.c: fix abuse of comma syntax

Fixes compiler diagnostics:

patricia.c:933:29: warning: possible misuse of comma operator
    here [-Wcomma]

patricia.c:935:29: warning: possible misuse of comma operator
    here [-Wcomma]

5 years agocontainer/index: initialise index_heap at load time
Aaron Jones [Fri, 18 Jan 2019 03:28:23 +0000 (03:28 +0000)] 
container/index: initialise index_heap at load time

Fixes compiler diagnostic:

index.c:34:1: warning: no previous prototype for function
    'mowgli_index_init' [-Wmissing-prototypes]

5 years agocore/bootstrap_internal.h: add missing header file to repository
Aaron Jones [Fri, 18 Jan 2019 03:25:14 +0000 (03:25 +0000)] 
core/bootstrap_internal.h: add missing header file to repository

git(1) keeps complaining that this file is being ignored by
.gitignore, which does not appear to be the case. Force add
it so that people can check out the repo and build it.

5 years agocontainer/dictionary.[ch]: fix numerous small issues
Aaron Jones [Fri, 18 Jan 2019 03:16:40 +0000 (03:16 +0000)] 
container/dictionary.[ch]: fix numerous small issues

The 4th diagnostic in particular is interesting because it is
located in unreachable code, so simply remove the entire
conditional block which is always false.

The 5th diagnostic is useful: it illuminated a missing function
declaration in the corresponding header, which was added.

Fixes compiler diagnostics:

dictionary.c:236:1: warning: no previous prototype for function
    'mowgli_dictionary_retune' [-Wmissing-prototypes]

dictionary.c:335:1: warning: no previous prototype for function
    'mowgli_dictionary_link' [-Wmissing-prototypes]

dictionary.c:414:1: warning: no previous prototype for function
    'mowgli_dictionary_unlink_root' [-Wmissing-prototypes]

dictionary.c:758:78: warning: cast from 'const void *' to 'void *'
    drops const qualifier [-Wcast-qual]

dictionary.c:846:1: warning: no previous prototype for function
    'mowgli_dictionary_size' [-Wmissing-prototypes]

5 years agocore/logger.c: mark compilation-unit private variables static
Aaron Jones [Fri, 18 Jan 2019 03:08:11 +0000 (03:08 +0000)] 
core/logger.c: mark compilation-unit private variables static

Fixes compiler diagnostics:

logger.c:29:6: warning: no previous extern declaration for non-static
    variable '_mowgli_log_buf' [-Wmissing-variable-declarations]

logger.c:30:17: warning: no previous extern declaration for non-static
    variable '_mowgli_log_cb' [-Wmissing-variable-declarations]

logger.c:33:1: warning: no previous prototype for function
    'mowgli_log_cb_default' [-Wmissing-prototypes]

5 years agocore/bootstrap.h: provide prototype for extern function 'mowgli_init'
Aaron Jones [Fri, 18 Jan 2019 03:05:47 +0000 (03:05 +0000)] 
core/bootstrap.h: provide prototype for extern function 'mowgli_init'

Fixes compiler diagnostic:

bootstrap.c:63:1: warning: no previous prototype for function
    'mowgli_init' [-Wmissing-prototypes]

5 years agocontainer/patricia: mowgli_patricia_create(): simplify in other terms
Aaron Jones [Tue, 15 Jan 2019 14:34:10 +0000 (14:34 +0000)] 
container/patricia: mowgli_patricia_create(): simplify in other terms

The Clang Static Analyzer identified that much of the code in
mowgli_patricia_create() was also present in the function beneath it,
mowgli_patricia_create_named().

Rewrite the former in terms of the latter.

5 years agocontainer/dictionary: mowgli_dictionary_create(): simplify in other terms
Aaron Jones [Tue, 15 Jan 2019 14:33:00 +0000 (14:33 +0000)] 
container/dictionary: mowgli_dictionary_create(): simplify in other terms

The Clang Static Analyzer identified that much of the code in
mowgli_dictionary_create() was also present in the function beneath it,
mowgli_dictionary_create_named().

Rewrite the former in terms of the latter.

Also fixes a bug where strdup(3) was used instead of mowgli_strdup().

5 years agocontainer/list: mowgli_list_concat(): fix possible NULL dereference
Aaron Jones [Tue, 15 Jan 2019 14:11:27 +0000 (14:11 +0000)] 
container/list: mowgli_list_concat(): fix possible NULL dereference

When concatenating a list onto an empty list, the code would dereference
the empty list's "tail" member even after checking that it is not NULL
(but not within this check, hence the problem). Move the dereference to
inside the conditional check block.

Also ensure that if the list being concatenated onto is empty, that its
"head" member is set appropriately too.

The former issue was identified by the Clang Static Analyzer.

Finally remove an "a = b = ..." idiom that trashes readability.

5 years agoAll Source Files: Lots of header/macro/function cleanups
Aaron Jones [Tue, 15 Jan 2019 13:40:31 +0000 (13:40 +0000)] 
All Source Files: Lots of header/macro/function cleanups

- Consistently use 2 spaces for preprocessor directive indentation

- Ensure all header files can successfully compile stand-alone

- Rearrange inclusions in alphabetical order; now that each header
  can build by itself, it doesn't matter what order you use them in

- Replace compiler attributes macro header wholesale with the one from
  Atheme IRC Services

- Add lots of missing function attributes where applicable

  Memory allocation attributes in particular will be useful for
  static analysis; but you can't just add the malloc attribute to
  every function returning a newly-allocated pointer. The malloc
  attribute is used to declare functions that return newly-allocated
  memory, and if that return value is a pointer to a newly-allocated
  structure, and some of its members point to memory that existed
  before the function was called, then it is not entirely newly-
  allocated memory, and the optimizer might generate broken code
  with the faulty assumption given to it. So, a careful audit was
  required to identify functions that allocated memory without setting
  pointers in the resulting structures to point to things that existed
  before the allocating function was called.

- Remove unnecessary includes from source files

- Fix 2 broken parameter-less function prototypes

- Avoid using "#elif" preprocessor directive where it does not result
  in uglier output

5 years agoAll Header Files: Use consistently-named & commented inclusion guards
Aaron Jones [Tue, 15 Jan 2019 10:12:22 +0000 (10:12 +0000)] 
All Header Files: Use consistently-named & commented inclusion guards

This names the include guards after the file path and comments the
endif at the bottom of the files too. It also instructs autoconf to
generate inclusion guards for the autoconf.h file that it writes out.

This avoids the include guards being named with reserved identifiers.
Identifiers that start with 2 underscores, or 1 underscore and then a
capital letter, should only be declared by system headers.

5 years agobuildsys.mk.in: clearly indicate link output file for 'make V=1' text
Aaron Jones [Wed, 19 Dec 2018 22:47:58 +0000 (22:47 +0000)] 
buildsys.mk.in: clearly indicate link output file for 'make V=1' text

This is the same as commit 34d4140ffdbdf06dd168 in Atheme IRC Services.

5 years agovio/vio_sockets.c: fix recvfrom(2) conditional check
Aaron Jones [Tue, 26 Jun 2018 23:05:04 +0000 (23:05 +0000)] 
vio/vio_sockets.c: fix recvfrom(2) conditional check

This defect was identified while compiling Atheme IRC Services
with the Clang Static Analyzer (version 7).

6 years agosrc/libmowgli/dns/evloop_res.c: fix epoll_ctl(2) -EBADF among others
Aaron Jones [Tue, 6 Mar 2018 21:05:08 +0000 (21:05 +0000)] 
src/libmowgli/dns/evloop_res.c: fix epoll_ctl(2) -EBADF among others

mowgli_dns_evloop_destroy() calls mowgli_vio_close(), which closes the
file descriptor. It then calls mowgli_vio_destroy(), which frees it from
the event loop, and then closes the file descriptor if it is not closed
already.

The problem is that closing a file descriptor removes it from any epoll
sets automatically, so the order of operations is incorrect and results
in:

epoll_pollops.c:86:mowgli_epoll_eventloop_destroy(): epoll_ctl failed:
    9 (Bad file descriptor)

Since mowgli_vio_destroy() will close it anyway, remove the call to
mowgli_vio_close().

6 years agosrc/libmowgli/dns/evloop_res.c: fix memory leak
Aaron Jones [Tue, 6 Mar 2018 19:51:04 +0000 (19:51 +0000)] 
src/libmowgli/dns/evloop_res.c: fix memory leak

mowgli_dns_evloop_init() [called by mowgli_dns_create()] allocates
a random number generator and assigns it to `dns->state->rand', but
mowgli_dns_evloop_destroy() [called by mowgli_dns_destroy()] does
not free this object.

This was found while running Atheme IRC Services (atheme/#621) under
Valgrind.

6 years agosrc/libmowgli/dns/evloop_res.c: fix erroneous invocation of memcpy(3)
Aaron Jones [Mon, 26 Feb 2018 04:24:01 +0000 (04:24 +0000)] 
src/libmowgli/dns/evloop_res.c: fix erroneous invocation of memcpy(3)

mowgli_dns_reslist_t.addr is a `struct sockaddr_storage', but
mowgli_dns_reply_t.addr is a `struct mowgli_vio_sockaddr',
which has both `struct sockaddr_storage' and `socklen_t'
members.

This makes mowgli_dns_reply_t.addr larger than
mowgli_dns_reslist_t.addr, but the size of the former is used
for the memory copy operation. This will result in an out-of-
bounds memory access while reading the smaller structure.

Explicitly copy to the sockaddr_storage structure within, and
use its size instead.

This was found by the Clang static analyzer while performing
an analysis on Atheme IRC Services.

6 years agosrc/libmowgli/base/argstack.c: remove erroneous invocation of va_end(3)
Aaron Jones [Mon, 26 Feb 2018 04:06:58 +0000 (04:06 +0000)] 
src/libmowgli/base/argstack.c: remove erroneous invocation of va_end(3)

The stdarg(3) manpage states:

va_end()
    Each invocation of va_start() must be matched by a cor‐
    responding invocation of va_end() in the *same function*.
    After the call va_end(ap) the variable ap is *undefined*.
    Multiple  traversals  of  the  list,  each bracketed by
    va_start() and va_end() are possible.  va_end() may  be
    a macro or a function.

(Emphasis mine)

However, va_start(3) was not called in this function, and
callers of mowgli_argstack_create_from_va_list() also call
va_end(3) after it returns. This means both that the varargs
will always be cleaned up, and if the function ran into an
error, it would erroneously clean it up and then the caller
would be invoking va_end(3) on an uninitialized list.

This was found by the Clang static analyzer while performing
an analysis on Atheme IRC Services.

6 years agoBuild System: Handle local macros via AC_CONFIG_MACRO_DIRS
Unit 193 [Wed, 7 Feb 2018 12:54:29 +0000 (13:54 +0100)] 
Build System: Handle local macros via AC_CONFIG_MACRO_DIRS

According to [1], this is the recommended way of handling local macros.

For some packagers, using the previous way broke autoreconf.

[1]: <https://www.gnu.org/software/automake/manual/html_node/Local-Macros.html>

6 years agoeventloop/epoll_pollops.c: zero epoll struct before use
Aaron Jones [Wed, 13 Dec 2017 12:45:31 +0000 (12:45 +0000)] 
eventloop/epoll_pollops.c: zero epoll struct before use

Valgrind warns that ->setselect() epoll_ctl(2) param &ep_event points to
uninitialised byte(s). This should resolve that.

6 years agocacheline: Ensure sysconf var is defined before use on Linux
A. Wilcox [Wed, 27 Sep 2017 06:42:33 +0000 (01:42 -0500)] 
cacheline: Ensure sysconf var is defined before use on Linux

6 years agom4/ax_check_openssl.m4: run pkg-config tests even if --with-openssl is given, if... v2.1.3
Aaron Jones [Fri, 15 Sep 2017 22:17:08 +0000 (22:17 +0000)] 
m4/ax_check_openssl.m4: run pkg-config tests even if --with-openssl is given, if it wasn't given a path

configure: update version to 2.1.3

Reported-By: Wade Cline <redacted>
6 years agom4/ax_check_openssl.m4: respect --with-openssl=yes in addition to =no v2.1.2
Aaron Jones [Tue, 12 Sep 2017 08:08:09 +0000 (08:08 +0000)] 
m4/ax_check_openssl.m4: respect --with-openssl=yes in addition to =no
configure: update version to 2.1.2

Reported-By: Wade Cline <redacted>
6 years agoconfigure: update version to 2.1.1 v2.1.1
Aaron Jones [Tue, 5 Sep 2017 05:11:50 +0000 (05:11 +0000)] 
configure: update version to 2.1.1

6 years agoOpenSSL: Several minor fixups
Aaron Jones [Tue, 5 Sep 2017 04:52:26 +0000 (04:52 +0000)] 
OpenSSL: Several minor fixups

- Respect --with-openssl=no and skip tests for building against it
- Test whether openssl/ec.h exists and conditionally build with that
  cf. https://bugs.gentoo.org/show_bug.cgi?id=629856

Usual huge diffstat from munging autotools files.

7 years agoREADME: remove broken link
Max Teufel [Sun, 4 Sep 2016 07:28:40 +0000 (09:28 +0200)] 
README: remove broken link

This link is unavailable, and probably won't be up at the same location,
if at all, again. Remove it.

Fixes atheme/libmowgli-2#38 ("README “More information is available at”
link broken")

8 years agoFix up several minor code quality problems that trigger clang warnings
Aaron Jones [Tue, 17 May 2016 04:16:02 +0000 (04:16 +0000)] 
Fix up several minor code quality problems that trigger clang warnings

Includes break statements that will never be executed, functions that
should be marked noreturn, and shadowed variable declarations.

8 years agoconfigure: update version to 2.1.0 v2.1.0
Max Teufel [Wed, 6 Apr 2016 15:32:31 +0000 (17:32 +0200)] 
configure: update version to 2.1.0

8 years agoMerge pull request #37 from staticfox/func
William Pitcock [Wed, 6 Apr 2016 15:28:42 +0000 (10:28 -0500)] 
Merge pull request #37 from staticfox/func

program_opts: Remove unused function

8 years agoprogram_opts: Remove unused function
Matt Ullman [Thu, 24 Mar 2016 01:32:05 +0000 (21:32 -0400)] 
program_opts: Remove unused function

8 years agoSeriously rework the OpenSSL context code
Aaron Jones [Mon, 16 Nov 2015 20:22:08 +0000 (20:22 +0000)] 
Seriously rework the OpenSSL context code

* Always negotiate the highest mutually supported protocol version
* Use the new TLS_{client,server}_method() APIs from OpenSSL 1.1.0
* Explicitly disable SSLv2 and SSLv3 if so available
* Support ECDH (either prime256v1 (< 1.0.2) or automatic (>= 1.0.2))

Closes #34

9 years agoMerge pull request #33 from Renegade334/master
William Pitcock [Sun, 22 Feb 2015 23:50:55 +0000 (17:50 -0600)] 
Merge pull request #33 from Renegade334/master

patricia.c: Fix assert in mowgli_patricia_elem_add

9 years agopatricia.c: Fix assert in mowgli_patricia_elem_add
Renegade334 [Wed, 11 Feb 2015 10:49:38 +0000 (10:49 +0000)] 
patricia.c: Fix assert in mowgli_patricia_elem_add
Change return_val_if_fail value to NULL (from FALSE) to match
return type.

9 years agoMerge pull request #32 from Renegade334/master
William Pitcock [Fri, 23 Jan 2015 02:38:44 +0000 (20:38 -0600)] 
Merge pull request #32 from Renegade334/master

vio/vio.c: mowgli_vio_err_sslerrcode: Return correct type from assertion

9 years agovio/vio.c: mowgli_vio_err_sslerrcode: Return correct type from assertion
Renegade334 [Wed, 21 Jan 2015 10:55:16 +0000 (10:55 +0000)] 
vio/vio.c: mowgli_vio_err_sslerrcode: Return correct type from assertion

9 years agoMerge pull request #31 from aji/master
William Pitcock [Thu, 15 Jan 2015 14:58:35 +0000 (08:58 -0600)] 
Merge pull request #31 from aji/master

Fix IPv6 reverse DNS lookups (address to name conversion)

9 years agoFix IPv6 reverse DNS lookups (address to name conversion)
Aaron Jones [Thu, 15 Jan 2015 07:05:25 +0000 (07:05 +0000)] 
Fix IPv6 reverse DNS lookups (address to name conversion)

The bug here is that it reverses the octets and appends a period
after each nibble, but then prepends a period before ip6.arpa.

This results in a query with 2 consecutive periods, which then
goes on to fail query validation and so the query is never sent.

I have no idea how this failed basic quality testing especially
since there is an example program that uses this functionality
that was apparently not even extended to try IPv6.

9 years agoCorrectly call <ctype.h> functions using (unsigned char) casts.
Jilles Tjoelker [Thu, 18 Dec 2014 14:38:43 +0000 (15:38 +0100)] 
Correctly call <ctype.h> functions using (unsigned char) casts.

9 years agoMerge pull request #27 from attilamolnar/vio-warn-fix
William Pitcock [Tue, 9 Sep 2014 15:19:07 +0000 (10:19 -0500)] 
Merge pull request #27 from attilamolnar/vio-warn-fix

vio: Change type of the flags parameter of mowgli_vio_{has,set}flag() to unsigned

9 years agoMerge pull request #26 from attilamolnar/heapdebug-compile-fix
William Pitcock [Sun, 3 Aug 2014 19:04:28 +0000 (14:04 -0500)] 
Merge pull request #26 from attilamolnar/heapdebug-compile-fix

core/heap: Fix compile error if HEAP_DEBUG is defined

9 years agoMerge pull request #29 from andrewshadura/patch-1
Mantas Mikulėnas [Tue, 17 Jun 2014 11:57:28 +0000 (14:57 +0300)] 
Merge pull request #29 from andrewshadura/patch-1

Use #else instead of #elif.

9 years agoUse #else instead of #elif.
Andrew Shadura [Tue, 17 Jun 2014 11:45:34 +0000 (13:45 +0200)] 
Use #else instead of #elif.

10 years agovio: Change type of the flags parameter of mowgli_vio_{has,set}flag() to unsigned
Attila Molnar [Mon, 28 Apr 2014 15:45:01 +0000 (17:45 +0200)] 
vio: Change type of the flags parameter of mowgli_vio_{has,set}flag() to unsigned

The 'flags' in struct _mowgli_vio is unsigned, this causes warnings with -Wsign-conversion

10 years agocore/heap: Fix compile error if HEAP_DEBUG is defined
Attila Molnar [Mon, 28 Apr 2014 15:42:11 +0000 (17:42 +0200)] 
core/heap: Fix compile error if HEAP_DEBUG is defined

10 years agoMerge pull request #25 from hlandau/master
Alex Iadicicco [Tue, 25 Feb 2014 03:57:16 +0000 (20:57 -0700)] 
Merge pull request #25 from hlandau/master

Make epoll/kqueue close-on-exec.

10 years agoMake DNS resolver's UDP socket close-on-exec.
Hugo Landau [Fri, 21 Feb 2014 10:00:57 +0000 (10:00 +0000)] 
Make DNS resolver's UDP socket close-on-exec.

10 years agoMake epoll/kqueue close-on-exec.
Hugo Landau [Fri, 21 Feb 2014 08:35:06 +0000 (08:35 +0000)] 
Make epoll/kqueue close-on-exec.

10 years agoMerge pull request #24 from awilfox/fix-std-c99
Alex Iadicicco [Thu, 6 Feb 2014 22:29:33 +0000 (15:29 -0700)] 
Merge pull request #24 from awilfox/fix-std-c99

Add compiler #error directive for glibc retadation

10 years agoAdd compiler #error directive for GCC retadation
Andrew Wilcox [Thu, 6 Feb 2014 10:58:55 +0000 (04:58 -0600)] 
Add compiler #error directive for GCC retadation

10 years agomodule/interface: new module, implementing cross-module API sharing
William Pitcock [Sun, 2 Feb 2014 19:02:38 +0000 (19:02 +0000)] 
module/interface: new module, implementing cross-module API sharing

10 years agodns/evloop_res: initialize lsin.addrlen
William Pitcock [Sun, 19 Jan 2014 06:51:04 +0000 (06:51 +0000)] 
dns/evloop_res: initialize lsin.addrlen

10 years agodns/evloop_res: initialize `lsin`.
William Pitcock [Sun, 19 Jan 2014 05:24:16 +0000 (05:24 +0000)] 
dns/evloop_res: initialize `lsin`.

10 years agoMerge branch 'master' of git://github.com/binki/libmowgli-2 (closes #20)
Alex Iadicicco [Sat, 2 Nov 2013 19:21:04 +0000 (12:21 -0700)] 
Merge branch 'master' of git://github.com/binki/libmowgli-2 (closes #20)

Conflicts:
src/libmowgli/platform/win32/win32_stdinc.h

10 years agoeventloop: Break timer run loop when no timers waiting.
Alex Iadicicco [Tue, 29 Oct 2013 04:46:22 +0000 (21:46 -0700)] 
eventloop: Break timer run loop when no timers waiting.

Also initialize deadline to -1 and delay an arbitrary 5 seconds when
no timers waiting.

10 years agoeventloop: Fix deadline for timers.
Jilles Tjoelker [Sun, 14 Jul 2013 10:46:27 +0000 (12:46 +0200)] 
eventloop: Fix deadline for timers.

If a timer is added while the deadline is not determined yet, the new
deadline only takes the new timer into account. This prevents execution
of other timers that should be run sooner.

11 years agogetopt_long: Fix missing newline after error messages.
Jilles Tjoelker [Sun, 21 Apr 2013 21:26:54 +0000 (23:26 +0200)] 
getopt_long: Fix missing newline after error messages.

Real warnx() appends a newline so make our substitute do so too.

11 years agoproctitle: fix undeclared identifier on certain platforms
Alex Iadicicco [Mon, 15 Apr 2013 08:05:52 +0000 (01:05 -0700)] 
proctitle: fix undeclared identifier on certain platforms

11 years agocacheline: make things work right on OS X
Alex Iadicicco [Mon, 15 Apr 2013 07:51:27 +0000 (00:51 -0700)] 
cacheline: make things work right on OS X

11 years agoMerge pull request #21 from quora-wings/master
William Pitcock [Sun, 14 Apr 2013 22:41:21 +0000 (15:41 -0700)] 
Merge pull request #21 from quora-wings/master

Fixed compiler warnings

11 years agoFixed unused variable warning in proctitle.c
Quora [Sun, 14 Apr 2013 22:04:14 +0000 (15:04 -0700)] 
Fixed unused variable warning in proctitle.c

11 years agoAdd limit.h to stdinc.h
Patrick McFarland [Sat, 6 Apr 2013 05:30:05 +0000 (01:30 -0400)] 
Add limit.h to stdinc.h

11 years agoMerge branch 'master' of https://github.com/atheme/libmowgli-2
Patrick McFarland [Sat, 6 Apr 2013 05:24:19 +0000 (01:24 -0400)] 
Merge branch 'master' of https://github.com/atheme/libmowgli-2

11 years agoMerge branch 'master' of https://github.com/Diablo-D3/libmowgli-2
Alex Iadicicco [Fri, 5 Apr 2013 02:46:30 +0000 (19:46 -0700)] 
Merge branch 'master' of https://github.com/Diablo-D3/libmowgli-2

Conflicts:
src/libmowgli/eventloop/ports_pollops.c

11 years agoFix description of mowgli_patricia routines. (ref #18)
William Pitcock [Wed, 27 Mar 2013 18:40:19 +0000 (13:40 -0500)] 
Fix description of mowgli_patricia routines. (ref #18)

11 years agoAdd BSDmakefile to redirect to gmake
Douglas Freed [Wed, 20 Mar 2013 09:09:06 +0000 (09:09 +0000)] 
Add BSDmakefile to redirect to gmake

11 years agoeventloop/ports: fix eventloop livelock
William Pitcock [Wed, 13 Mar 2013 23:12:10 +0000 (18:12 -0500)] 
eventloop/ports: fix eventloop livelock