Giter VIP home page Giter VIP logo

libasr's Issues

build error on OS X: conflicting types for 'snprintf'

so far I used only OpenBSD version

today, Iโ€™m trying to compile OpenSMTPD cloned from git on OS X

Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64

instructions from README.md

during make, I ended with

Making all in openbsd-compat
gcc -DHAVE_CONFIG_H -I. -I.. -I../smtpd -I../openbsd-compat -I/opt/local -I/opt/local -g -O2 -Qunused-arguments -Wunknown-warning-option -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -fno-builtin-memset -c -o arc4random.o arc4random.c
In file included from arc4random.c:27:
In file included from ./includes.h:77:
./openbsd-compat.h:152:5: warning: incompatible redeclaration of library function 'snprintf' [-Wincompatible-library-redeclaration]
int snprintf(char , size_t, SNPRINTF_CONST char *, ...);
^
./openbsd-compat.h:152:5: note: 'snprintf' is a builtin with type 'int (char *, unsigned long, const char *, ...)'
1 warning generated.
gcc -DHAVE_CONFIG_H -I. -I.. -I../smtpd -I../openbsd-compat -I/opt/local -I/opt/local -g -O2 -Qunused-arguments -Wunknown-warning-option -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -fno-builtin-memset -c -o base64.o base64.c
In file included from base64.c:47:
In file included from ./includes.h:77:
./openbsd-compat.h:152:5: warning: incompatible redeclaration of library function 'snprintf' [-Wincompatible-library-redeclaration]
int snprintf(char *, size_t, SNPRINTF_CONST char *, ...);
^
./openbsd-compat.h:152:5: note: 'snprintf' is a builtin with type 'int (char *, unsigned long, const char *, ...)'
In file included from base64.c:58:
/usr/include/stdio.h:421:6: error: conflicting types for 'snprintf'
int snprintf(char * __restrict, size_t, const char * __restrict, ...) __printflike(3, 4);
^
./openbsd-compat.h:152:5: note: previous declaration is here
int snprintf(char *, size_t, SNPRINTF_CONST char *, ...);
^
1 warning and 1 error generated.
make[2]: *
* [base64.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

patch: automake subdir-objects

Problem:

[...]
configure.ac:44: installing './missing'
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/fgetln.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
automake-1.15: warning: possible forward-incompatibility.
automake-1.15: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.15: automake option hasn't been enabled. For now, the corresponding output
automake-1.15: object file(s) will be placed in the top-level directory. However,
automake-1.15: this behaviour will change in future Automake versions: they will
automake-1.15: unconditionally cause object files to be placed in the same subdirectory
automake-1.15: of the corresponding sources.
automake-1.15: You are advised to start using 'subdir-objects' option throughout your
automake-1.15: project, to avoid future incompatibilities.
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/res_hnok.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/strlcat.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/strlcpy.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/strsep.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
src/Makefile.am:3: warning: source file '$(top_srcdir)/openbsd-compat/strtonum.c' is in a subdirectory,
src/Makefile.am:3: but option 'subdir-objects' is disabled
src/Makefile.am: installing './depcomp'
[...]

Patch:

perl -i.bak -ple 's|^AM_INIT_AUTOMAKE$|AM_INIT_AUTOMAKE([subdir-objects])|' configure.ac;

Result:

[...]
configure.ac:44: installing './missing'
src/Makefile.am: installing './depcomp'

  • rm -Rf autom4te.cache
    [...]

Comments:
no comment

Incorrect compat definition of NETDB_SUCCESS

On systems such as Linux with musl that do not define NETDB_SUCCESS, the definition from openbsd-compat/defines.h is used. This definition uses the wrong number, -1, which is defined immediately above to signify an internal error. OpenSMTPD expects the value to be zero on success, which matches the glibc definition. As it is now, this causes all DNS lookups in OpenSMTPD to hit the failure case here, and so mail fails to relay with smtp-out: Failed to resolve MX for [relay:domain.tld]: Temporary failure in MX lookup.

There is an appropriate patch here in #10

Build fails on Slackware 14.2

Hi

I'm trying to build libasr master, which fails, unlike when building version 1.0.2.

The goal is to be able to build OpenSMTPD with all the latest tweaks and features for testing, rather than working with stable and then having to change things when the next stable is out.

Is it absolutely necessary to be using master for libasr in order to build master for OpenSMTPD at this point?

$ git clone git://github.com/OpenSMTPD/libasr.git
$ cd libasr
$ ./bootstrap
$ CFLAGS="-O2 -fPIC -fstack-protector" CXXFLAGS="-O2 -fPIC -fstack-protector" ./configure --prefix=/pkg/libasr/20180820 --enable-static=no --build=x86_64-slackware-linux
$ make
make  all-recursive
make[1]: Entering directory `/home/admin/src/opensmtpd/libasr/libasr'
Making all in src
make[2]: Entering directory `/home/admin/src/opensmtpd/libasr/libasr/src'
Makefile:414: ../openbsd-compat/.deps/libasr_la-clock_gettime.Plo: No such file or directory
Makefile:415: ../openbsd-compat/.deps/libasr_la-fgetln.Plo: No such file or directory
Makefile:416: ../openbsd-compat/.deps/libasr_la-reallocarray.Plo: No such file or directory
Makefile:417: ../openbsd-compat/.deps/libasr_la-res_hnok.Plo: No such file or directory
Makefile:418: ../openbsd-compat/.deps/libasr_la-strlcat.Plo: No such file or directory
Makefile:419: ../openbsd-compat/.deps/libasr_la-strlcpy.Plo: No such file or directory
Makefile:420: ../openbsd-compat/.deps/libasr_la-strsep.Plo: No such file or directory
Makefile:421: ../openbsd-compat/.deps/libasr_la-strtonum.Plo: No such file or directory
make[2]: *** No rule to make target `../openbsd-compat/.deps/libasr_la-strtonum.Plo'.  Stop.
make[2]: Leaving directory `/home/admin/src/opensmtpd/libasr/libasr/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/admin/src/opensmtpd/libasr/libasr'
make: *** [all] Error 2

I'm unfamiliar with building Makefiles, so unsure where to begin looking for this issue.

Could someone take a peek at this or point me in the right direction?

Thanks

New release

Hello, I'm building packages for my operating system, and I could use a new release with the last modifications on the master branch.

Currently, I have an automake with version 0.16 and it's not working with the last release (but works fine with master).

Thanks!

libasr 1.0.3 lacks an explicit_bzero replacement function if it's missing

I tried to built opensmtpd 6.6.1p1 on CentOS 7, but it exited with the following error:

...
checking for asr.h... yes
checking for asr_run in -lasr... no
configure: error: *** libasr missing - please install first or check config.log ***

I had already successfuly built libasr 1.0.3 from git OpenSMTPD/libasr and added it to ldconfig by writing a config file /etc/ld.so.conf.d/libasr.conf with the following content: /usr/local/lib/; and then running $ sudo ldconfig.

$ ldconfig -p | grep libasr shows:
libasr.so.0 (libc6,x86-64) => /usr/local/lib/libasr.so.0
libasr.so (libc6,x86-64) => /usr/local/lib/libasr.so

Here is the config.log from attempting the OpenSMTPd ./configure step.

The error in there is: .../builds/opensmtpd/conftest.c:133: undefined reference to explicit_bzero'` on line 10988.

Add res_randomid

libasr has copied many resolver functions from OpenBSD. However the function res_randomid(), which is used in res_send_async() and res_mkquery() seems to have been forgotten.

Because of this libasr currently only works with glibc and uclibc>=0.9.33 as these libc's provide the function. It however seems to be a non-standard function with no real documentation.

Could res_randomid() be provided, inclusion possibly depending on a configure test?

1.0.4: gcc 10 comile time warnings

It would be good to clean those warnings.

asr.c: In function '_asr_strdname':
asr.c:789:31: warning: pointer targets in initialization of 'const unsigned char *' from 'const char *' differ in signedness [-Wpointer-sign]
  789 |  const unsigned char *dname = _dname;
      |                               ^~~~~~
In file included from asr_private.h:20,
                 from asr.c:39:
At top level:
asr_compat.h:22:26: warning: '__thread_name__asr' defined but not used [-Wunused-variable]
   22 | #define __THREAD_NAME(x) __thread_name_ ## x
      |                          ^~~~~~~~~~~~~~
asr.c:61:14: note: in expansion of macro '__THREAD_NAME'
   61 | static void *__THREAD_NAME(_asr);
      |              ^~~~~~~~~~~~~
res_send_async.c: In function 'res_send_async':
res_send_async.c:80:23: warning: pointer targets in passing argument 2 of '_asr_unpack_init' differ in signedness [-Wpointer-sign]
   80 |  _asr_unpack_init(&p, buf, buflen);
      |                       ^~~
      |                       |
      |                       const unsigned char *
In file included from res_send_async.c:39:
asr_private.h:296:44: note: expected 'const char *' but argument is of type 'const unsigned char *'
  296 | void _asr_unpack_init(struct asr_unpack *, const char *, size_t);
      |                                            ^~~~~~~~~~~~
res_send_async.c: In function 'setup_query':
res_send_async.c:399:31: warning: pointer targets in passing argument 2 of '_asr_pack_init' differ in signedness [-Wpointer-sign]
  399 |  _asr_pack_init(&p, as->as.dns.obuf, as->as.dns.obufsize);
      |                     ~~~~~~~~~~^~~~~
      |                               |
      |                               unsigned char *
In file included from res_send_async.c:39:
asr_private.h:292:40: note: expected 'char *' but argument is of type 'unsigned char *'
  292 | void _asr_pack_init(struct asr_pack *, char *, size_t);
      |                                        ^~~~~~
res_send_async.c: In function 'tcp_read':
res_send_async.c:643:6: warning: pointer targets in assignment from 'unsigned char *' to 'char *' differ in signedness [-Wpointer-sign]
  643 |  pos = as->as.dns.ibuf + offset;
      |      ^
res_send_async.c: In function 'ensure_ibuf':
res_send_async.c:692:18: warning: pointer targets in assignment from 'char *' to 'unsigned char *' differ in signedness [-Wpointer-sign]
  692 |  as->as.dns.ibuf = t;
      |                  ^
res_send_async.c: In function 'validate_packet':
res_send_async.c:711:33: warning: pointer targets in passing argument 2 of '_asr_unpack_init' differ in signedness [-Wpointer-sign]
  711 |  _asr_unpack_init(&p, as->as.dns.ibuf, as->as.dns.ibuflen);
      |                       ~~~~~~~~~~^~~~~
      |                                 |
      |                                 unsigned char *
In file included from res_send_async.c:39:
asr_private.h:296:44: note: expected 'const char *' but argument is of type 'unsigned char *'
  296 | void _asr_unpack_init(struct asr_unpack *, const char *, size_t);
      |                                            ^~~~~~~~~~~~
asr_utils.c: In function 'dname_expand':
asr_utils.c:144:39: warning: pointer targets in passing argument 1 of 'dname_check_label' differ in signedness [-Wpointer-sign]
  144 |   if (dname_check_label(data + offset + 1, n) == -1)
      |                         ~~~~~~~~~~~~~~^~~
      |                                       |
      |                                       const unsigned char *
asr_utils.c:58:31: note: expected 'const char *' but argument is of type 'const unsigned char *'
   58 | dname_check_label(const char *s, size_t l)
      |                   ~~~~~~~~~~~~^
asr_utils.c: In function 'unpack_dname':
asr_utils.c:246:20: warning: pointer targets in passing argument 1 of 'dname_expand' differ in signedness [-Wpointer-sign]
  246 |  e = dname_expand(p->buf, p->len, p->offset, &p->offset, dst, max);
      |                   ~^~~~~
      |                    |
      |                    const char *
asr_utils.c:117:35: note: expected 'const unsigned char *' but argument is of type 'const char *'
  117 | dname_expand(const unsigned char *data, size_t len, size_t offset,
      |              ~~~~~~~~~~~~~~~~~~~~~^~~~
getaddrinfo_async.c: In function 'get_port':
getaddrinfo_async.c:479:18: warning: unused variable 'se' [-Wunused-variable]
  479 |  struct servent  se;
      |                  ^~

Using AI_CANONNAME on systems that do not defined AI_FQDN causes BADFLAGS error

Executing the following test code in Alpine Linux will result in a BADFLAGS error.

#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <asr.h>

int main() {
    struct asr_query *query;
    struct asr_result result;
    struct addrinfo hints;
    const char *hostname = "www.yahoo.co.jp";

    memset(&hints, 0, sizeof(hints));
    hints.ai_flags = AI_CANONNAME;
    query = getaddrinfo_async(hostname, NULL, &hints, NULL);
    asr_run_sync(query, &result);
    if (errno != 0) {
        printf("asr run error: %s\n", strerror(errno));
        return 1;
    } else if (result.ar_gai_errno) {
        printf("gataddrinfo error: %s\n", gai_strerror(result.ar_gai_errno));
        return 1;
    }
    return 0;
}
$ cc test.c -lasr
$ ./a.out 
gataddrinfo error: Invalid flags

Only of the AI_CANONNAME and AI_FQDN bits can be set, Only the AI_CANONNAME and AI_FQDN bits can be set, and are verified in getaddrinfo_async_run() as follows:

if (ai->ai_flags & ~AI_MASK ||
(ai->ai_flags & AI_CANONNAME && ai->ai_flags & AI_FQDN)) {
ar->ar_gai_errno = EAI_BADFLAGS;
async_set_state(as, ASR_STATE_HALT);
break;
}

However, on systems such as Linux with musl that do not define AI_FQDN, it is defined as AI_CANONNAME at build time:

libasr/src/asr_compat.h

Lines 42 to 44 in 15fdb71

#ifndef AI_FQDN
#define AI_FQDN AI_CANONNAME
#endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.