Skip to content

Commit

Permalink
Use strlcpy() instead of strncpy() with -f arg
Browse files Browse the repository at this point in the history
Add a safety check for argument length too
  • Loading branch information
koitsu committed Dec 21, 2017
1 parent 22b06c3 commit 813b283
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ main(int argc, char *argv[])
comma_output = 1;
break;
case 'f':
strncpy(smbdev, optarg, MAXPATHLEN);
if (strlcpy(smbdev, optarg, MAXPATHLEN) >= MAXPATHLEN) {
warn("Device pathname exceeds %u bytes in length", MAXPATHLEN);
exitcode = EX_SOFTWARE;
goto finish;
}
break;
case 'l':
list_models(&boardlist);
Expand Down

0 comments on commit 813b283

Please sign in to comment.