Skip to content

Commit

Permalink
rc_map2id: avoid usage of strlcat
Browse files Browse the repository at this point in the history
  • Loading branch information
nmav authored and arr2036 committed Mar 2, 2015
1 parent 9beeb27 commit a25afc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/clientid.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ uint32_t rc_map2id(rc_handle const *rh, char const *name)
{
struct map2id_s *p;
char ttyname[PATH_MAX];
unsigned pos = 0;

*ttyname = '\0';
if (*name != '/')
if (*name != '/') {
strcpy(ttyname, "/dev/");
pos = 5;
}

strlcat(ttyname, name, sizeof(ttyname)-strlen(ttyname));
strlcpy(&ttyname[pos], name, sizeof(ttyname)-pos);

for(p = rh->map2id_list; p; p = p->next)
if (!strcmp(ttyname, p->name)) return p->id;
Expand Down

0 comments on commit a25afc5

Please sign in to comment.