]> git.ozlabs.org Git - ppp.git/blobdiff - pppdump/pppdump.c
pppdump: Avoid out-of-range access to packet buffer
[ppp.git] / pppdump / pppdump.c
index 8944ca5820012589658f435a3b238e598db07d47..b85a86271edacafcbae3f7329bce4e08bf5b0b94 100644 (file)
@@ -38,7 +38,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <sys/types.h>
-#include <net/ppp_defs.h>
+
 #include "ppp-comp.h"
 
 int hexmode;
@@ -297,6 +297,10 @@ dumpppp(f)
                            printf("%s aborted packet:\n     ", dir);
                            q = "    ";
                        }
+                       if (pkt->cnt >= sizeof(pkt->buf)) {
+                           printf("%s over-long packet truncated:\n     ", dir);
+                           q = "    ";
+                       }
                        nb = pkt->cnt;
                        p = pkt->buf;
                        pkt->cnt = 0;
@@ -400,7 +404,8 @@ dumpppp(f)
                        c ^= 0x20;
                        pkt->esc = 0;
                    }
-                   pkt->buf[pkt->cnt++] = c;
+                   if (pkt->cnt < sizeof(pkt->buf))
+                       pkt->buf[pkt->cnt++] = c;
                    break;
                }
            }