Page MenuHomePhabricator

0.7.6 strndup issue with visual studio
Closed, ResolvedPublic

Description

See https://ci.appveyor.com/project/chcg/nppftp/build/job/7920dv59ivffy9li

After update from libssh 0.7.5 -> 0.7.6 there is an linker issue:

Creating library ssh.lib and object ssh.exp

dh.c.obj : error LNK2019: unresolved external symbol _strndup referenced in function _ssh_get_b64_unpadded [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

Seems strndup is a gcc only feature (https://en.cppreference.com/w/c/experimental/dynamic/strndup) and fallback impl in misc.c was not merged:

#if !defined(HAVE_STRNDUP)
char *strndup(const char *s, size_t n)
{

char *x = NULL;

if (n + 1 < n) {
    return NULL;
}

x = malloc(n + 1);
if (x == NULL) {
    return NULL;
}

memcpy(x, s, n);
x[n] = '\0';

return x;

}
#endif /* ! HAVE_STRNDUP */

Related Objects

Event Timeline

chcg created this task.Oct 17 2018, 3:59 AM
chcg added a comment.Oct 29 2018, 8:08 PM

See https://ci.appveyor.com/project/chcg/nppftp/builds/19888936. x64 builds are fine, but x86 not. Definition for size_t is missing. Seems some include is missing. Compiler issue:

[ 12%] Building C object src/CMakeFiles/ssh_shared.dir/ecdh.c.obj

ecdh.c

C:\projects\nppftp\_build\x86\obj\libssh\include\libssh/priv.h(47): error C2146: syntax error: missing ')' before identifier 'n' [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

C:\projects\nppftp\_build\x86\obj\libssh\include\libssh/priv.h(47): error C2081: 'size_t': name in formal parameter list illegal [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

C:\projects\nppftp\_build\x86\obj\libssh\include\libssh/priv.h(47): error C2061: syntax error: identifier 'n' [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

C:\projects\nppftp\_build\x86\obj\libssh\include\libssh/priv.h(47): error C2059: syntax error: ';' [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

C:\projects\nppftp\_build\x86\obj\libssh\include\libssh/priv.h(47): error C2059: syntax error: ')' [C:\projects\nppftp\_build\NppFTP3rdPartyPrerequists.vcxproj]

Should I create a new ticket for this?

asn added a subscriber: asn.Oct 29 2018, 9:13 PM

Yes, please. Open a new bug do we need to explicitly include stddef.h in priv.h?