summaryrefslogtreecommitdiffstats
path: root/cpukit/ftpd
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-05 14:47:21 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-05 14:47:21 +0200
commit51da629b2adad350765ba5218791285609f2d33f (patch)
tree9c5d86a54117c2c66a669b4df3498411e92ed577 /cpukit/ftpd
parentftpd: Remove FTPD_SessionInfo_t::pass member (diff)
downloadrtems-51da629b2adad350765ba5218791285609f2d33f.tar.bz2
ftpd: Avoid malloc() and sscanf()
Move the user name to the session information. Update #3530.
Diffstat (limited to 'cpukit/ftpd')
-rw-r--r--cpukit/ftpd/ftpd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/cpukit/ftpd/ftpd.c b/cpukit/ftpd/ftpd.c
index fb67335c0c..25656134fb 100644
--- a/cpukit/ftpd/ftpd.c
+++ b/cpukit/ftpd/ftpd.c
@@ -265,6 +265,7 @@ typedef struct
int xfer_mode; /* Transfer mode (ASCII/binary) */
rtems_id tid; /* Task id */
char *user; /* user name (0 if not supplied) */
+ char user_buf[256]; /* user name buffer */
bool auth; /* true if user/pass was valid, false if not or not supplied */
} FTPD_SessionInfo_t;
@@ -1736,9 +1737,8 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
}
else if (!strcmp("USER", cmd))
{
- sscanf(args, "%254s", fname);
- free(info->user);
- info->user = strdup(fname);
+ strlcpy(info->user_buf, args, sizeof(info->user_buf));
+ info->user = info->user_buf;
if (ftpd_config->login &&
!ftpd_config->login(info->user, NULL)) {
info->auth = false;
@@ -1944,7 +1944,6 @@ session(rtems_task_argument arg)
/* Close connection and put ourselves back into the task pool. */
close_data_socket(info);
close_stream(info);
- free(info->user);
task_pool_release(info);
}
}