mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-17 06:18:58 +03:00
Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
0dce42c8fd
commit
d92e389a80
16
src/bind.c
16
src/bind.c
@@ -79,6 +79,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
|||||||
int opt = 1;
|
int opt = 1;
|
||||||
socket_t s;
|
socket_t s;
|
||||||
int rc;
|
int rc;
|
||||||
|
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
|
||||||
|
|
||||||
ZERO_STRUCT(hints);
|
ZERO_STRUCT(hints);
|
||||||
|
|
||||||
@@ -98,7 +99,8 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
|||||||
ai->ai_socktype,
|
ai->ai_socktype,
|
||||||
ai->ai_protocol);
|
ai->ai_protocol);
|
||||||
if (s == SSH_INVALID_SOCKET) {
|
if (s == SSH_INVALID_SOCKET) {
|
||||||
ssh_set_error(sshbind, SSH_FATAL, "%s", strerror(errno));
|
ssh_set_error(sshbind, SSH_FATAL, "%s",
|
||||||
|
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
freeaddrinfo (ai);
|
freeaddrinfo (ai);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -108,7 +110,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
|||||||
ssh_set_error(sshbind,
|
ssh_set_error(sshbind,
|
||||||
SSH_FATAL,
|
SSH_FATAL,
|
||||||
"Setting socket options failed: %s",
|
"Setting socket options failed: %s",
|
||||||
strerror(errno));
|
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
freeaddrinfo (ai);
|
freeaddrinfo (ai);
|
||||||
CLOSE_SOCKET(s);
|
CLOSE_SOCKET(s);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -120,7 +122,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
|||||||
"Binding to %s:%d: %s",
|
"Binding to %s:%d: %s",
|
||||||
hostname,
|
hostname,
|
||||||
port,
|
port,
|
||||||
strerror(errno));
|
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
freeaddrinfo (ai);
|
freeaddrinfo (ai);
|
||||||
CLOSE_SOCKET(s);
|
CLOSE_SOCKET(s);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -280,9 +282,10 @@ int ssh_bind_listen(ssh_bind sshbind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (listen(fd, 10) < 0) {
|
if (listen(fd, 10) < 0) {
|
||||||
|
char err_msg[] = {0};
|
||||||
ssh_set_error(sshbind, SSH_FATAL,
|
ssh_set_error(sshbind, SSH_FATAL,
|
||||||
"Listening to socket %d: %s",
|
"Listening to socket %d: %s",
|
||||||
fd, strerror(errno));
|
fd, ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
CLOSE_SOCKET(fd);
|
CLOSE_SOCKET(fd);
|
||||||
ssh_key_free(sshbind->dsa);
|
ssh_key_free(sshbind->dsa);
|
||||||
sshbind->dsa = NULL;
|
sshbind->dsa = NULL;
|
||||||
@@ -586,14 +589,15 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session)
|
|||||||
|
|
||||||
fd = accept(sshbind->bindfd, NULL, NULL);
|
fd = accept(sshbind->bindfd, NULL, NULL);
|
||||||
if (fd == SSH_INVALID_SOCKET) {
|
if (fd == SSH_INVALID_SOCKET) {
|
||||||
|
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
ssh_set_error(sshbind, SSH_EINTR,
|
ssh_set_error(sshbind, SSH_EINTR,
|
||||||
"Accepting a new connection (child signal error): %s",
|
"Accepting a new connection (child signal error): %s",
|
||||||
strerror(errno));
|
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
} else {
|
} else {
|
||||||
ssh_set_error(sshbind, SSH_FATAL,
|
ssh_set_error(sshbind, SSH_FATAL,
|
||||||
"Accepting a new connection: %s",
|
"Accepting a new connection: %s",
|
||||||
strerror(errno));
|
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||||
}
|
}
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user