otp: Copy strings with explicit limiting
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Wed, 10 Sep 2014 11:06:38 +0000 (14:06 +0300)
committerNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Wed, 10 Sep 2014 14:04:35 +0000 (17:04 +0300)
commitd7619f2d8ed7dd31cf49aef8b977efcfac8a0a1c
tree51000f664d0b114dcc88f3177aabd10f7f2ed5c4
parent8bdbe58367de8337df4678efc1e14ed0b36b8782
otp: Copy strings with explicit limiting

When copying username, challenge and password in otp_pw_valid, use
strlcpy accepting explicit destination size and verify its result,
instead of first assuming or verifying the string will fit and then
doing unlimited strcpy.

This silences the following Coverity errors.

Error: STRING_OVERFLOW (CWE-120):
freeradius-server-3.0.4rc2/src/modules/rlm_otp/otp_pw_valid.c:89: fixed_size_dest: You might overrun the 32 byte fixed-size string "otp_request.username" by copying "username" without checking the length.

Error: STRING_OVERFLOW (CWE-120):
freeradius-server-3.0.4rc2/src/modules/rlm_otp/otp_pw_valid.c:90: fixed_size_dest: You might overrun the 17 byte fixed-size string "otp_request.challenge" by copying "challenge" without checking the length.
freeradius-server-3.0.4rc2/src/modules/rlm_otp/otp_pw_valid.c:90: parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.

Error: STRING_OVERFLOW (CWE-120):
freeradius-server-3.0.4rc2/src/modules/rlm_otp/otp_pw_valid.c:122: fixed_size_dest: You might overrun the 48 byte fixed-size string "otp_request.pwe.u.pap.passcode" by copying "rvp->data.strvalue" without checking the length.
src/modules/rlm_otp/otp_pw_valid.c