mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-02 10:53:16 +03:00
Fix or silence all C compiler warnings discovered with (or without) `PICKY_COMPILER=ON` (in CMake). This means all warnings showing up in CI (gcc, clang, MSVS 2013/2015), in local tests on macOS (clang 14) and Windows cross-builds using gcc (12) and llvm/clang (14/15). Also fix the expression `nread -= nread` in `sftp_RW_nonblock.c`. Cherry-picked from: #846 Closes #861
41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#include "session_fixture.h"
|
|
#include "runner.h"
|
|
|
|
#include <libssh2.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
|
static const char *KEY_FILE_PRIVATE = "key_dsa_wrong";
|
|
static const char *KEY_FILE_PUBLIC = "key_dsa_wrong.pub";
|
|
|
|
int test(LIBSSH2_SESSION *session)
|
|
{
|
|
int rc;
|
|
|
|
const char *userauth_list =
|
|
libssh2_userauth_list(session, USERNAME,
|
|
(unsigned int)strlen(USERNAME));
|
|
if(userauth_list == NULL) {
|
|
print_last_session_error("libssh2_userauth_list");
|
|
return 1;
|
|
}
|
|
|
|
if(strstr(userauth_list, "publickey") == NULL) {
|
|
fprintf(stderr, "'publickey' was expected in userauth list: %s\n",
|
|
userauth_list);
|
|
return 1;
|
|
}
|
|
|
|
rc = libssh2_userauth_publickey_fromfile_ex(
|
|
session, USERNAME, (unsigned int)strlen(USERNAME),
|
|
srcdir_path(KEY_FILE_PUBLIC), srcdir_path(KEY_FILE_PRIVATE),
|
|
NULL);
|
|
if(rc == 0) {
|
|
fprintf(stderr, "Public-key auth succeeded with wrong key\n");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|