Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Jun 2015 03:06:50 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   [Bug 200723] security/libressl fails to statically link
Message-ID:  <bug-200723-13@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200723

            Bug ID: 200723
           Summary: security/libressl fails to statically link
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: vsevolod@FreeBSD.org
          Reporter: loox@e-shell.net
          Assignee: vsevolod@FreeBSD.org
             Flags: maintainer-feedback?(vsevolod@FreeBSD.org)

This is a sample program:

#include <stdlib.h>
#include <openssl/ssl.h>
#include <curl/curl.h>

int main()
{
    SSL_library_init();
    arc4random();
    curl_easy_init();

    return (0);
}

% clang -I /usr/local/include -L /usr/local/lib arc.c -o arc -static -l curl -l
z -l cares -l ssl -l crypto
/usr/lib/libc.a(arc4random.o): In function `arc4random':
/usr/src/lib/libc/gen/arc4random.c:(.text+0x350): multiple definition of
`arc4random'
/usr/local/lib/libcrypto.a(libcompat_la-arc4random.o):(.text+0x0): first
defined here
/usr/lib/libc.a(arc4random.o): In function `arc4random_buf':
/usr/src/lib/libc/gen/arc4random.c:(.text+0x4c0): multiple definition of
`arc4random_buf'
/usr/local/lib/libcrypto.a(libcompat_la-arc4random.o):(.text+0xa0): first
defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation


curl is linked to libressl

Now a simple patch that makes the above program link:

cat /usr/ports/security/libressl/files/patch-crypto-compat-arc4random.c
--- crypto/compat/arc4random.c.orig     2015-06-08 21:06:50.000000000 -0500
+++ crypto/compat/arc4random.c  2015-06-08 21:07:03.000000000 -0500
@@ -176,7 +176,7 @@
 }

 uint32_t
-arc4random(void)
+arc4random_(void)
 {
        uint32_t val;

@@ -187,7 +187,7 @@
 }

 void
-arc4random_buf(void *buf, size_t n)
+arc4random_buf_(void *buf, size_t n)
 {
        _ARC4_LOCK();
        _rs_random_buf(buf, n);


With this, the program links correctly.

The configure of the port:

checking dependency style of cc... gcc3
checking for arc4random_buf... (cached) yes
checking for asprintf... (cached) yes


And that file is compiled:

--- compat/libcompat_la-timingsafe_bcmp.lo ---
  CC       compat/libcompat_la-timingsafe_bcmp.lo
--- compat/libcompat_la-arc4random.lo ---
  CC       compat/libcompat_la-arc4random.lo
--- compat/libcompat_la-getentropy_freebsd.lo ---
  CC       compat/libcompat_la-getentropy_freebsd.lo


For what I can see, this shouldn't be compiled if arc4random_buf is detected.

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-200723-13>