aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/capi
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2014-10-11 07:46:30 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-14 15:05:34 -0400
commit5510ab18048397193ae073d6b0d4ea78ff0170f5 (patch)
tree1f78a2f37ba05126f902cd5be66c37414a4c6683 /drivers/isdn/capi
parent854d23b77aa25b203c7af11de885c3b8b3834c20 (diff)
isdn/capi: prevent NULL pointer dereference on invalid CAPI command
An invalid CAPI 2.0 command/subcommand combination may retrieve a NULL pointer from the cpars[] array which will later be dereferenced by the parser routines. Fix by adding NULL pointer checks in strategic places. Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/capi')
-rw-r--r--drivers/isdn/capi/capiutil.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c
index 8e401eda2aa1..36835ef3f340 100644
--- a/drivers/isdn/capi/capiutil.c
+++ b/drivers/isdn/capi/capiutil.c
@@ -318,6 +318,8 @@ unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg)
318 cmsg->l = 8; 318 cmsg->l = 8;
319 cmsg->p = 0; 319 cmsg->p = 0;
320 cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); 320 cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand);
321 if (!cmsg->par)
322 return 1; /* invalid command/subcommand */
321 323
322 pars_2_message(cmsg); 324 pars_2_message(cmsg);
323 325
@@ -391,6 +393,8 @@ unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg)
391 byteTRcpy(cmsg->m + 4, &cmsg->Command); 393 byteTRcpy(cmsg->m + 4, &cmsg->Command);
392 byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); 394 byteTRcpy(cmsg->m + 5, &cmsg->Subcommand);
393 cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); 395 cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand);
396 if (!cmsg->par)
397 return 1; /* invalid command/subcommand */
394 398
395 message_2_pars(cmsg); 399 message_2_pars(cmsg);
396 400
@@ -640,6 +644,9 @@ static _cdebbuf *printstruct(_cdebbuf *cdb, u8 *m)
640 644
641static _cdebbuf *protocol_message_2_pars(_cdebbuf *cdb, _cmsg *cmsg, int level) 645static _cdebbuf *protocol_message_2_pars(_cdebbuf *cdb, _cmsg *cmsg, int level)
642{ 646{
647 if (!cmsg->par)
648 return NULL; /* invalid command/subcommand */
649
643 for (; TYP != _CEND; cmsg->p++) { 650 for (; TYP != _CEND; cmsg->p++) {
644 int slen = 29 + 3 - level; 651 int slen = 29 + 3 - level;
645 int i; 652 int i;