Skip to content

Commit

Permalink
Fix plugin argument
Browse files Browse the repository at this point in the history
This broke in the re-exec changes, it was altering the argv
argument in-place, but argv was re-used later.

Fixes #194 github issue
  • Loading branch information
mkj committed Nov 9, 2022
1 parent 9d320a7 commit ab6ea4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
6 changes: 4 additions & 2 deletions runopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ typedef struct svr_runopts {
char * forced_command;

#if DROPBEAR_PLUGIN
char *pubkey_plugin;
char *pubkey_plugin_options;
/* malloced */
char *pubkey_plugin;
/* points into pubkey_plugin */
char *pubkey_plugin_options;
#endif

int pass_on_env;
Expand Down
18 changes: 9 additions & 9 deletions svr-runopts.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,15 @@ void svr_getopts(int argc, char ** argv) {
#endif

#if DROPBEAR_PLUGIN
if (pubkey_plugin) {
char *args = strchr(pubkey_plugin, ',');
if (args) {
*args='\0';
++args;
}
svr_opts.pubkey_plugin = pubkey_plugin;
svr_opts.pubkey_plugin_options = args;
}
if (pubkey_plugin) {
svr_opts.pubkey_plugin = m_strdup(pubkey_plugin);
char *args = strchr(svr_opts.pubkey_plugin, ',');
if (args) {
*args='\0';
++args;
}
svr_opts.pubkey_plugin_options = args;
}
#endif
}

Expand Down
12 changes: 7 additions & 5 deletions svr-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void svr_session(int sock, int childpipe) {

}

/* failure exit - format must be <= 100 chars */
/* cleanup and exit - format must be <= 100 chars */
void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
char exitmsg[150];
char fullmsg[300];
Expand All @@ -217,10 +217,12 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
int add_delay = 0;

#if DROPBEAR_PLUGIN
if ((ses.plugin_session != NULL)) {
svr_ses.plugin_instance->delete_session(ses.plugin_session);
}
ses.plugin_session = NULL;
if ((ses.plugin_session != NULL)) {
svr_ses.plugin_instance->delete_session(ses.plugin_session);
}
ses.plugin_session = NULL;
svr_opts.pubkey_plugin_options = NULL;
m_free(svr_opts.pubkey_plugin);
#endif

/* Render the formatted exit message */
Expand Down

0 comments on commit ab6ea4d

Please sign in to comment.