Message ID | 51396845.3050600@asianux.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Chen Gang <gang.chen@asianux.com> Date: Fri, 08 Mar 2013 12:25:41 +0800 > > sizeof (cmd.parm.cmsg.para) is 50 (MAX_CAPI_PARA_LEN). > sizeof (cmd.parm) is 80+, but less than 100. > strlen(msg) may be more than 80+ (Modem-Commandbuffer, less than 255). > isdn_tty_send_msg is called by isdn_tty_parse_at > the relative parameter is m->mdmcmd (atemu *m) > the relative command may be "+M..." > > so need check the length to be sure not memory overflow. > cmd.parm is a union, and need keep original valid buffer length no touch > > > Signed-off-by: Chen Gang <gang.chen@asianux.com> Applied. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index d8a7d83..ebaebdf 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -902,7 +902,9 @@ isdn_tty_send_msg(modem_info *info, atemu *m, char *msg) int j; int l; - l = strlen(msg); + l = min(strlen(msg), sizeof(cmd.parm) - sizeof(cmd.parm.cmsg) + + sizeof(cmd.parm.cmsg.para) - 2); + if (!l) { isdn_tty_modem_result(RESULT_ERROR, info); return;
sizeof (cmd.parm.cmsg.para) is 50 (MAX_CAPI_PARA_LEN). sizeof (cmd.parm) is 80+, but less than 100. strlen(msg) may be more than 80+ (Modem-Commandbuffer, less than 255). isdn_tty_send_msg is called by isdn_tty_parse_at the relative parameter is m->mdmcmd (atemu *m) the relative command may be "+M..." so need check the length to be sure not memory overflow. cmd.parm is a union, and need keep original valid buffer length no touch Signed-off-by: Chen Gang <gang.chen@asianux.com> --- drivers/isdn/i4l/isdn_tty.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)