2019-12-18 Anthony Green <green@moxielogic.com>
[deliverable/binutils-gdb.git] / gdb / gdbserver / hostio.c
index d2b5a71bade904343d54349f2e01980b3d822d5e..e35a2249be92cd6cd32a71c8f198ef6e63a7456b 100644 (file)
@@ -1,5 +1,5 @@
 /* Host file transfer support for gdbserver.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -27,9 +27,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "fileio.h"
-
-extern int remote_debug;
+#include "gdbsupport/fileio.h"
 
 struct fd_list
 {
@@ -96,22 +94,27 @@ static int
 require_int (char **pp, int *value)
 {
   char *p;
-  int count;
+  int count, firstdigit;
 
   p = *pp;
   *value = 0;
   count = 0;
+  firstdigit = -1;
 
   while (*p && *p != ',')
     {
       int nib;
 
-      /* Don't allow overflow.  */
-      if (count >= 7)
+      if (safe_fromhex (p[0], &nib))
        return -1;
 
-      if (safe_fromhex (p[0], &nib))
+      if (firstdigit == -1)
+       firstdigit = nib;
+
+      /* Don't allow overflow.  */
+      if (count >= 8 || (count == 7 && firstdigit >= 0x8))
        return -1;
+
       *value = *value * 16 + nib;
       p++;
       count++;
This page took 0.02918 seconds and 4 git commands to generate.