Changeset 51da629 in rtems for cpukit


Ignore:
Timestamp:
Oct 5, 2018, 12:47:21 PM (11 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
479a28e0
Parents:
dcf42bb2
Message:

ftpd: Avoid malloc() and sscanf()

Move the user name to the session information.

Update #3530.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ftpd/ftpd.c

    rdcf42bb2 r51da629  
    266266  rtems_id            tid;         /* Task id */
    267267  char                *user;       /* user name (0 if not supplied) */
     268  char                user_buf[256]; /* user name buffer */
    268269  bool                auth;        /* true if user/pass was valid, false if not or not supplied */
    269270} FTPD_SessionInfo_t;
     
    17371738  else if (!strcmp("USER", cmd))
    17381739  {
    1739     sscanf(args, "%254s", fname);
    1740     free(info->user);
    1741     info->user = strdup(fname);
     1740    strlcpy(info->user_buf, args, sizeof(info->user_buf));
     1741    info->user = info->user_buf;
    17421742    if (ftpd_config->login &&
    17431743      !ftpd_config->login(info->user, NULL)) {
     
    19451945    close_data_socket(info);
    19461946    close_stream(info);
    1947     free(info->user);
    19481947    task_pool_release(info);
    19491948  }
Note: See TracChangeset for help on using the changeset viewer.