1
1

messages: Some cleanup for ssh_packet_service_request

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Andreas Schneider 2018-09-25 16:00:26 +02:00
родитель 54ec81db2d
Коммит bc72ec5821

Просмотреть файл

@ -613,41 +613,38 @@ void ssh_message_free(ssh_message msg){
SSH_PACKET_CALLBACK(ssh_packet_service_request) SSH_PACKET_CALLBACK(ssh_packet_service_request)
{ {
ssh_string service = NULL;
char *service_c = NULL; char *service_c = NULL;
ssh_message msg = NULL; ssh_message msg = NULL;
int rc;
(void)type; (void)type;
(void)user; (void)user;
service = ssh_buffer_get_ssh_string(packet); rc = ssh_buffer_unpack(packet,
if (service == NULL) { "s",
&service_c);
if (rc != SSH_OK) {
ssh_set_error(session, ssh_set_error(session,
SSH_FATAL, SSH_FATAL,
"Invalid SSH_MSG_SERVICE_REQUEST packet"); "Invalid SSH_MSG_SERVICE_REQUEST packet");
goto error; goto error;
} }
service_c = ssh_string_to_char(service);
if (service_c == NULL) {
goto error;
}
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
"Received a SERVICE_REQUEST for service %s", "Received a SERVICE_REQUEST for service %s",
service_c); service_c);
msg = ssh_message_new(session); msg = ssh_message_new(session);
if (msg == NULL) { if (msg == NULL) {
SAFE_FREE(service_c); SAFE_FREE(service_c);
goto error; goto error;
} }
msg->type=SSH_REQUEST_SERVICE; msg->type = SSH_REQUEST_SERVICE;
msg->service_request.service=service_c; msg->service_request.service = service_c;
ssh_message_queue(session, msg);
error: error:
ssh_string_free(service);
if (msg != NULL) {
ssh_message_queue(session, msg);
}
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }