Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#19213 closed defect (fixed)

Build failure on mingw-64

Reported by: bc348 Owned by:
Priority: Medium Milestone: Tor: 0.2.9.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: 028-backport
Cc: Actual Points: 0
Parent ID: Points: .1
Reviewer: nickm Sponsor:

Description

test.exe build error: undefined reference to sscanf
(gcc 5.3.0 x86_64-w64-mingw32 with -flto enabled)

https://gitweb.torproject.org/tor.git/tree/src/test/test_util.c#n4667

test/test_util.c line 4667:  int n = sscanf(contents, "%lu\n%c", &pid, &c);

Need tor_sscanf

Child Tickets

Change History (6)

comment:1 Changed 4 years ago by cypherpunks

Component: Core TorCore Tor/Tor
Status: newneeds_review
diff --git b/src/test/test_util.c a/src/test/test_util.c
index 2726c31..c3c6035 100644
--- b/src/test/test_util.c
+++ a/src/test/test_util.c
@@ -4664,7 +4664,7 @@ test_util_writepid(void *arg)
   contents = read_file_to_str(fname, 0, NULL);
   tt_assert(contents);
 
-  int n = sscanf(contents, "%lu\n%c", &pid, &c);
+  int n = tor_sscanf(contents, "%lu\n%c", &pid, &c);
   tt_int_op(n, OP_EQ, 1);
 
 #ifdef _WIN32

comment:2 Changed 4 years ago by cypherpunks

Another instance

diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index e6b250a..c128333 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -162,7 +162,7 @@ test_crypto_openssl_version(void *arg)
   tt_assert(!strcmpstart(version, h_version)); /* "-fips" suffix, etc */
   tt_assert(!strstr(version, "OpenSSL"));
   int a=-1,b=-1,c=-1;
-  sscanf(version, "%d.%d.%d", &a,&b,&c);
+  tor_sscanf(version, "%d.%d.%d", &a,&b,&c);
   tt_int_op(a, OP_GE, 0);
   tt_int_op(b, OP_GE, 0);
   tt_int_op(c, OP_GE, 0);

comment:3 Changed 4 years ago by nickm

Keywords: 028-backport added
Milestone: Tor: 0.2.9.x-final
Points: .1

Strange -- I agree that we should be using tor_sscanf, even in the tests, but isn't sscanf supposed to be in libc?

comment:4 in reply to:  3 Changed 4 years ago by cypherpunks

Replying to nickm:

Strange -- I agree that we should be using tor_sscanf, even in the tests, but isn't sscanf supposed to be in libc?

It seems mingw-w64 does not have an implementation for the scanf family [0].

[0] https://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/

comment:5 Changed 4 years ago by nickm

Actual Points: 0
Resolution: fixed
Reviewer: nickm
Status: needs_reviewclosed

Okay, changes applied to 0.2.7, 0.2.8, 0.2.9 as appropriate.

comment:6 Changed 3 years ago by arma

Summary: Build failureBuild failure on mingw-64
Note: See TracTickets for help on using tickets.