Skip to content

Commit c64ec43

Browse files
committed
src: Remove enter_function() and leave_function().
1 parent 0d3deee commit c64ec43

22 files changed

+268
-495
lines changed

include/libssh/priv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ int gettimeofday(struct timeval *__p, void *__t);
138138
# define LIBSSH_THREAD
139139
#endif
140140

141-
#define enter_function() (void)session
142-
#define leave_function() (void)session
143-
144141
#ifdef HAVE_SYS_TIME_H
145142
#include <sys/time.h>
146143
#endif

include/libssh/session.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ struct ssh_common_struct {
8484
struct error_struct error;
8585
ssh_callbacks callbacks; /* Callbacks to user functions */
8686
int log_verbosity; /* verbosity of the log functions */
87-
int log_indent; /* indentation level in enter_function logs */
8887
};
8988

9089
struct ssh_session_struct {

src/auth.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ static int ssh_userauth_get_response(ssh_session session) {
110110
rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
111111
ssh_auth_response_termination, session);
112112
if (rc == SSH_ERROR) {
113-
leave_function();
114113
return SSH_AUTH_ERROR;
115114
}
116115
if (!ssh_auth_response_termination(session)){
117-
leave_function();
118116
return SSH_AUTH_AGAIN;
119117
}
120118

@@ -159,7 +157,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_banner){
159157
ssh_string banner;
160158
(void)type;
161159
(void)user;
162-
enter_function();
160+
163161
banner = buffer_get_ssh_string(packet);
164162
if (banner == NULL) {
165163
SSH_LOG(SSH_LOG_WARN,
@@ -171,7 +169,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_banner){
171169
ssh_string_free(session->banner);
172170
session->banner = banner;
173171
}
174-
leave_function();
172+
175173
return SSH_PACKET_USED;
176174
}
177175

@@ -188,7 +186,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_failure){
188186
uint8_t partial = 0;
189187
(void) type;
190188
(void) user;
191-
enter_function();
192189

193190
auth = buffer_get_ssh_string(packet);
194191
if (auth == NULL || buffer_get_u8(packet, &partial) != 1) {
@@ -239,7 +236,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_failure){
239236
end:
240237
ssh_string_free(auth);
241238
SAFE_FREE(auth_methods);
242-
leave_function();
239+
243240
return SSH_PACKET_USED;
244241
}
245242

@@ -251,7 +248,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_failure){
251248
* It is also used to communicate the new to the upper levels.
252249
*/
253250
SSH_PACKET_CALLBACK(ssh_packet_userauth_success){
254-
enter_function();
255251
(void)packet;
256252
(void)type;
257253
(void)user;
@@ -271,7 +267,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_success){
271267
SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression IN");
272268
session->current_crypto->do_compress_in=1;
273269
}
274-
leave_function();
270+
275271
return SSH_PACKET_USED;
276272
}
277273

@@ -285,7 +281,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_success){
285281
*/
286282
SSH_PACKET_CALLBACK(ssh_packet_userauth_pk_ok){
287283
int rc;
288-
enter_function();
289284

290285
SSH_LOG(SSH_LOG_TRACE, "Received SSH_USERAUTH_PK_OK/INFO_REQUEST/GSSAPI_RESPONSE");
291286

@@ -303,7 +298,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_pk_ok){
303298
SSH_LOG(SSH_LOG_TRACE, "Assuming SSH_USERAUTH_PK_OK");
304299
rc=SSH_PACKET_USED;
305300
}
306-
leave_function();
301+
307302
return rc;
308303
}
309304

@@ -1740,7 +1735,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
17401735
uint32_t i;
17411736
(void)user;
17421737
(void)type;
1743-
enter_function();
17441738

17451739
name = buffer_get_ssh_string(packet);
17461740
instruction = buffer_get_ssh_string(packet);
@@ -1754,7 +1748,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
17541748
ssh_string_free(name);
17551749
ssh_string_free(instruction);
17561750
ssh_set_error(session, SSH_FATAL, "Invalid USERAUTH_INFO_REQUEST msg");
1757-
leave_function();
1751+
17581752
return SSH_PACKET_USED;
17591753
}
17601754

@@ -1765,7 +1759,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
17651759
ssh_string_free(name);
17661760
ssh_string_free(instruction);
17671761

1768-
leave_function();
17691762
return SSH_PACKET_USED;
17701763
}
17711764
} else {
@@ -1778,7 +1771,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
17781771
ssh_set_error_oom(session);
17791772
ssh_kbdint_free(session->kbdint);
17801773
ssh_string_free(instruction);
1781-
leave_function();
1774+
17821775
return SSH_PACKET_USED;
17831776
}
17841777

@@ -1788,7 +1781,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
17881781
ssh_set_error_oom(session);
17891782
ssh_kbdint_free(session->kbdint);
17901783
session->kbdint = NULL;
1791-
leave_function();
1784+
17921785
return SSH_PACKET_USED;
17931786
}
17941787

@@ -1801,7 +1794,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
18011794
nprompts, nprompts);
18021795
ssh_kbdint_free(session->kbdint);
18031796
session->kbdint = NULL;
1804-
leave_function();
1797+
18051798
return SSH_PACKET_USED;
18061799
}
18071800

@@ -1813,7 +1806,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
18131806
ssh_set_error_oom(session);
18141807
ssh_kbdint_free(session->kbdint);
18151808
session->kbdint = NULL;
1816-
leave_function();
1809+
18171810
return SSH_PACKET_USED;
18181811
}
18191812
memset(session->kbdint->prompts, 0, nprompts * sizeof(char *));
@@ -1824,7 +1817,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
18241817
ssh_set_error_oom(session);
18251818
ssh_kbdint_free(session->kbdint);
18261819
session->kbdint = NULL;
1827-
leave_function();
1820+
18281821
return SSH_PACKET_USED;
18291822
}
18301823
memset(session->kbdint->echo, 0, nprompts);
@@ -1836,7 +1829,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
18361829
ssh_set_error(session, SSH_FATAL, "Short INFO_REQUEST packet");
18371830
ssh_kbdint_free(session->kbdint);
18381831
session->kbdint = NULL;
1839-
leave_function();
1832+
18401833
return SSH_PACKET_USED;
18411834
}
18421835
session->kbdint->prompts[i] = ssh_string_to_char(tmp);
@@ -1846,12 +1839,12 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
18461839
session->kbdint->nprompts = i;
18471840
ssh_kbdint_free(session->kbdint);
18481841
session->kbdint = NULL;
1849-
leave_function();
1842+
18501843
return SSH_PACKET_USED;
18511844
}
18521845
}
18531846
session->auth_state=SSH_AUTH_STATE_INFO;
1854-
leave_function();
1847+
18551848
return SSH_PACKET_USED;
18561849
}
18571850

src/auth1.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ static int ssh_auth_status_termination(void *s){
4444
}
4545

4646
static int wait_auth1_status(ssh_session session) {
47-
enter_function();
4847
/* wait for a packet */
4948
if (ssh_handle_packets_termination(session,SSH_TIMEOUT_USER,
5049
ssh_auth_status_termination, session) != SSH_OK){
51-
leave_function();
50+
5251
return SSH_AUTH_ERROR;
5352
}
5453
SSH_LOG(SSH_LOG_PROTOCOL,"Auth state : %d",session->auth_state);
55-
leave_function();
54+
5655
switch(session->auth_state) {
5756
case SSH_AUTH_STATE_SUCCESS:
5857
return SSH_AUTH_SUCCESS;
@@ -153,19 +152,17 @@ int ssh_userauth1_offer_pubkey(ssh_session session, const char *username,
153152
(void) username;
154153
(void) type;
155154
(void) pubkey;
156-
enter_function();
157-
leave_function();
155+
158156
return SSH_AUTH_DENIED;
159157
}
160158

161159
int ssh_userauth1_password(ssh_session session, const char *username,
162160
const char *password) {
163161
ssh_string pwd = NULL;
164162
int rc;
165-
enter_function();
163+
166164
rc = send_username(session, username);
167165
if (rc != SSH_AUTH_DENIED) {
168-
leave_function();
169166
return rc;
170167
}
171168
if (session->pending_call_state == SSH_PENDING_CALL_AUTH_PASSWORD)
@@ -181,7 +178,6 @@ int ssh_userauth1_password(ssh_session session, const char *username,
181178
/* not risky to disclose the size of such a big password .. */
182179
pwd = ssh_string_from_char(password);
183180
if (pwd == NULL) {
184-
leave_function();
185181
return SSH_AUTH_ERROR;
186182
}
187183
} else {
@@ -194,7 +190,6 @@ int ssh_userauth1_password(ssh_session session, const char *username,
194190
*/
195191
pwd = ssh_string_new(sizeof(buf));
196192
if (pwd == NULL) {
197-
leave_function();
198193
return SSH_AUTH_ERROR;
199194
}
200195
ssh_get_random(buf, sizeof(buf), 0);
@@ -205,13 +200,13 @@ int ssh_userauth1_password(ssh_session session, const char *username,
205200
if (buffer_add_u8(session->out_buffer, SSH_CMSG_AUTH_PASSWORD) < 0) {
206201
ssh_string_burn(pwd);
207202
ssh_string_free(pwd);
208-
leave_function();
203+
209204
return SSH_AUTH_ERROR;
210205
}
211206
if (buffer_add_ssh_string(session->out_buffer, pwd) < 0) {
212207
ssh_string_burn(pwd);
213208
ssh_string_free(pwd);
214-
leave_function();
209+
215210
return SSH_AUTH_ERROR;
216211
}
217212

@@ -220,14 +215,13 @@ int ssh_userauth1_password(ssh_session session, const char *username,
220215
session->auth_state=SSH_AUTH_STATE_NONE;
221216
session->pending_call_state = SSH_PENDING_CALL_AUTH_PASSWORD;
222217
if (packet_send(session) == SSH_ERROR) {
223-
leave_function();
224218
return SSH_AUTH_ERROR;
225219
}
226220
pending:
227221
rc = wait_auth1_status(session);
228222
if (rc != SSH_AUTH_AGAIN)
229223
session->pending_call_state = SSH_PENDING_CALL_NONE;
230-
leave_function();
224+
231225
return rc;
232226
}
233227

src/callbacks.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ int ssh_set_callbacks(ssh_session session, ssh_callbacks cb) {
3030
if (session == NULL || cb == NULL) {
3131
return SSH_ERROR;
3232
}
33-
enter_function();
33+
3434
if(cb->size <= 0 || cb->size > 1024 * sizeof(void *)){
3535
ssh_set_error(session,SSH_FATAL,
3636
"Invalid callback passed in (badly initialized)");
37-
leave_function();
37+
3838
return SSH_ERROR;
3939
}
4040
session->common.callbacks = cb;
41-
leave_function();
41+
4242
return 0;
4343
}
4444

@@ -48,30 +48,30 @@ int ssh_set_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb) {
4848
return SSH_ERROR;
4949
}
5050
session = channel->session;
51-
enter_function();
51+
5252
if(cb->size <= 0 || cb->size > 1024 * sizeof(void *)){
5353
ssh_set_error(session,SSH_FATAL,
5454
"Invalid channel callback passed in (badly initialized)");
55-
leave_function();
55+
5656
return SSH_ERROR;
5757
}
5858
channel->callbacks = cb;
59-
leave_function();
59+
6060
return 0;
6161
}
6262

6363
int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb){
6464
if (session == NULL || cb == NULL) {
6565
return SSH_ERROR;
6666
}
67-
enter_function();
67+
6868
if(cb->size <= 0 || cb->size > 1024 * sizeof(void *)){
6969
ssh_set_error(session,SSH_FATAL,
7070
"Invalid callback passed in (badly initialized)");
71-
leave_function();
71+
7272
return SSH_ERROR;
7373
}
7474
session->server_callbacks = cb;
75-
leave_function();
75+
7676
return 0;
7777
}

0 commit comments

Comments
 (0)