[kgtp] r946 committed - Fix bug with GDB RSP package sum check.

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Wed, 29 Feb 2012 12:29:08 +0000

Revision: 946
Author:   teawater
Date:     Wed Feb 29 04:28:19 2012
Log:      Fix bug with GDB RSP package sum check.

http://code.google.com/p/kgtp/source/detail?r=946

Modified:
 /trunk/Makefile
 /trunk/UPDATE
 /trunk/dkms.conf
 /trunk/gtp.c
 /trunk/gtp_for_review.patch

=======================================
--- /trunk/Makefile     Mon Feb 27 02:34:48 2012
+++ /trunk/Makefile     Wed Feb 29 04:28:19 2012
@@ -1,6 +1,6 @@
 obj-m := gtp.o

-MODULEVERSION := 20120224
+MODULEVERSION := 20120224+

 KERNELVERSION := $(shell uname -r)
 KERNELDIR := /lib/modules/$(KERNELVERSION)/build/
=======================================
--- /trunk/UPDATE       Mon Feb 27 02:37:40 2012
+++ /trunk/UPDATE       Wed Feb 29 04:28:19 2012
@@ -1,3 +1,7 @@
+*** 20120224+
+
+* Fix bug with GDB RSP package sum check.
+
 *** 20120224

 * https://lkml.org/lkml/2012/2/26/127
=======================================
--- /trunk/dkms.conf    Thu Feb 23 23:02:43 2012
+++ /trunk/dkms.conf    Wed Feb 29 04:28:19 2012
@@ -1,5 +1,5 @@
 PACKAGE_NAME="gtp"
-PACKAGE_VERSION="20120224"
+PACKAGE_VERSION="20120224+"
 CLEAN="make clean"
 MAKE[0]="make gtp.ko KERNELVERSION=$kernelver"
 BUILT_MODULE_NAME[0]="gtp"
=======================================
--- /trunk/gtp.c        Sat Feb 25 02:36:54 2012
+++ /trunk/gtp.c        Wed Feb 29 04:28:19 2012
@@ -19,8 +19,8 @@
  *
  */

-/* If *10 means that this is not a release version.  */
-#define GTP_VERSION                    (20120224)
+/* If "* 10" means that this is not a release version.  */
+#define GTP_VERSION                    (20120224 * 10)

 #include <linux/version.h>
 #ifndef RHEL_RELEASE_VERSION
@@ -247,7 +247,7 @@
 #define GTP_FRAME_VAR_SIZE     (FID_SIZE + sizeof(struct gtp_frame_var))
 #endif

-#define TOHEX(h)               ((h) > 9 ? (h) + 'a' - 10 : (h) + '0')
+#define INT2CHAR(h)            ((h) > 9 ? (h) + 'a' - 10 : (h) + '0')

 struct action_agent_exp {
        unsigned int    size;
@@ -7690,13 +7690,13 @@
        }
        if (rsppkg && gtp_rw_buf[i] == '#') {
                /* Format is OK.  Check crc.  */
-               unsigned char   c1, c2;
+               int             c1, c2;

                gtp_rw_buf[i] = '\0';

-               c1 = gtp_rw_buf[i+1];
-               c2 = gtp_rw_buf[i+2];
-               if (csum == (c1 << 4) + c2) {
+               if (!hex2int(gtp_rw_buf[i+1], &c1)
+                   || !hex2int(gtp_rw_buf[i+2], &c2)
+                   || csum != (c1 << 4) + c2) {
 #ifdef GTP_DEBUG
                        printk(GTP_DEBUG "gtp_write: crc error\n");
 #endif
@@ -7791,8 +7791,8 @@
        csum = 0;
        for (i = 1; i < gtp_rw_size + 1; i++)
                csum += gtp_rw_buf[i];
-       gtp_rw_bufp[1] = TOHEX(csum >> 4);
-       gtp_rw_bufp[2] = TOHEX(csum & 0x0f);
+       gtp_rw_bufp[1] = INT2CHAR(csum >> 4);
+       gtp_rw_bufp[2] = INT2CHAR(csum & 0x0f);
        gtp_rw_bufp = gtp_rw_buf;
        gtp_rw_size += 4;

=======================================
--- /trunk/gtp_for_review.patch Sat Feb 25 02:36:54 2012
+++ /trunk/gtp_for_review.patch Wed Feb 29 04:28:19 2012
@@ -1974,8 +1974,8 @@
 + *
 + */
 +
-+/* If *10 means that this is not a release version.  */
-+#define GTP_VERSION                   (20120224)
++/* If "* 10" means that this is not a release version.  */
++#define GTP_VERSION                   (20120224 * 10)
 +
 +#include <linux/version.h>
 +#include <linux/kernel.h>
@@ -2054,7 +2054,7 @@
 +#endif
 +#include <linux/perf_event.h>
 +
-+#define TOHEX(h)              ((h) > 9 ? (h) + 'a' - 10 : (h) + '0')
++#define INT2CHAR(h)           ((h) > 9 ? (h) + 'a' - 10 : (h) + '0')
 +
 +struct action_agent_exp {
 +      unsigned int    size;
@@ -9099,13 +9099,13 @@
 +      }
 +      if (rsppkg && gtp_rw_buf[i] == '#') {
 +              /* Format is OK.  Check crc.  */
-+              unsigned char   c1, c2;
++              int             c1, c2;
 +
 +              gtp_rw_buf[i] = '\0';
 +
-+              c1 = gtp_rw_buf[i+1];
-+              c2 = gtp_rw_buf[i+2];
-+              if (csum == (c1 << 4) + c2) {
++              if (!hex2int(gtp_rw_buf[i+1], &c1)
++                  || !hex2int(gtp_rw_buf[i+2], &c2)
++                  || csum != (c1 << 4) + c2) {
 +#ifdef GTP_DEBUG
 +                      printk(GTP_DEBUG "gtp_write: crc error\n");
 +#endif
@@ -9200,8 +9200,8 @@
 +      csum = 0;
 +      for (i = 1; i < gtp_rw_size + 1; i++)
 +              csum += gtp_rw_buf[i];
-+      gtp_rw_bufp[1] = TOHEX(csum >> 4);
-+      gtp_rw_bufp[2] = TOHEX(csum & 0x0f);
++      gtp_rw_bufp[1] = INT2CHAR(csum >> 4);
++      gtp_rw_bufp[2] = INT2CHAR(csum & 0x0f);
 +      gtp_rw_bufp = gtp_rw_buf;
 +      gtp_rw_size += 4;
 +

Other related posts:

  • » [kgtp] r946 committed - Fix bug with GDB RSP package sum check. - kgtp