Changeset: c69b9b2695a5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c69b9b2695a5
Modified Files:
        monetdb5/modules/mal/remote.c
Branch: Jul2017
Log Message:

Properly check for nil:oid from remote end.


diffs (127 lines):

diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1177,61 +1177,74 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
 
                                lvp = &lv;
                                len = (int) sizeof(lv);
-                               /* all values should be non-negative, so we 
check that
-                                * here as well */
-                               if (lngFromStr(val, &len, &lvp) == 0 ||
-                                       lv < 0 /* includes lng_nil */)
-                                       throw(MAL, "remote.bincopyfrom",
-                                                 "bad %s value: %s", nme, val);
-
-                               /* deal with nme and val */
-                               if (strcmp(nme, "version") == 0) {
-                                       if (lv != 1)
-                                               throw(MAL, "remote.bincopyfrom",
-                                                               "unsupported 
version: %s", val);
-                               } else if (strcmp(nme, "hseqbase") == 0) {
-#if SIZEOF_OID < SIZEOF_LNG
-                                       if (lv > GDK_oid_max)
-                                               throw(MAL, "remote.bincopyfrom",
-                                                         "bad %s value: %s", 
nme, val);
+                               /* tseqbase can be 1<<31/1<<63 which causes 
overflow
+                                * in lngFromStr, so we check separately */
+                               if (strcmp(val,
+#if SIZEOF_OID == 8
+                                                  "9223372036854775808"
+#else
+                                                  "2147483648"
 #endif
-                                       bb.Hseqbase = (oid)lv;
-                               } else if (strcmp(nme, "ttype") == 0) {
-                                       if (lv >= GDKatomcnt)
+                                               ) == 0 &&
+                                       strcmp(nme, "tseqbase") == 0) {
+                                       bb.Tseqbase = oid_nil;
+                               } else {
+                                       /* all values should be non-negative, 
so we check that
+                                        * here as well */
+                                       if (lngFromStr(val, &len, &lvp) == 0 ||
+                                               lv < 0 /* includes lng_nil */)
                                                throw(MAL, "remote.bincopyfrom",
                                                          "bad %s value: %s", 
nme, val);
-                                       bb.Ttype = (int) lv;
-                               } else if (strcmp(nme, "tseqbase") == 0) {
+
+                                       /* deal with nme and val */
+                                       if (strcmp(nme, "version") == 0) {
+                                               if (lv != 1)
+                                                       throw(MAL, 
"remote.bincopyfrom",
+                                                                 "unsupported 
version: %s", val);
+                                       } else if (strcmp(nme, "hseqbase") == 
0) {
 #if SIZEOF_OID < SIZEOF_LNG
-                                       if (lv > GDK_oid_max)
-                                               throw(MAL, "remote.bincopyfrom",
-                                                         "bad %s value: %s", 
nme, val);
+                                               if (lv > GDK_oid_max)
+                                                       throw(MAL, 
"remote.bincopyfrom",
+                                                                         "bad 
%s value: %s", nme, val);
 #endif
-                                       bb.Tseqbase = (oid) lv;
-                               } else if (strcmp(nme, "tsorted") == 0) {
-                                       bb.Tsorted = lv != 0;
-                               } else if (strcmp(nme, "trevsorted") == 0) {
-                                       bb.Trevsorted = lv != 0;
-                               } else if (strcmp(nme, "hkey") == 0) {
-                                       bb.Hkey = lv != 0;
-                               } else if (strcmp(nme, "tkey") == 0) {
-                                       bb.Tkey = lv != 0;
-                               } else if (strcmp(nme, "tnonil") == 0) {
-                                       bb.Tnonil = lv != 0;
-                               } else if (strcmp(nme, "tdense") == 0) {
-                                       bb.Tdense = lv != 0;
-                               } else if (strcmp(nme, "size") == 0) {
-                                       if (lv > (lng) BUN_MAX)
+                                               bb.Hseqbase = (oid)lv;
+                                       } else if (strcmp(nme, "ttype") == 0) {
+                                               if (lv >= GDKatomcnt)
+                                                       throw(MAL, 
"remote.bincopyfrom",
+                                                                 "bad %s 
value: %s", nme, val);
+                                               bb.Ttype = (int) lv;
+                                       } else if (strcmp(nme, "tseqbase") == 
0) {
+#if SIZEOF_OID < SIZEOF_LNG
+                                               if (lv > GDK_oid_max)
+                                                       throw(MAL, 
"remote.bincopyfrom",
+                                                                 "bad %s 
value: %s", nme, val);
+#endif
+                                               bb.Tseqbase = (oid) lv;
+                                       } else if (strcmp(nme, "tsorted") == 0) 
{
+                                               bb.Tsorted = lv != 0;
+                                       } else if (strcmp(nme, "trevsorted") == 
0) {
+                                               bb.Trevsorted = lv != 0;
+                                       } else if (strcmp(nme, "hkey") == 0) {
+                                               bb.Hkey = lv != 0;
+                                       } else if (strcmp(nme, "tkey") == 0) {
+                                               bb.Tkey = lv != 0;
+                                       } else if (strcmp(nme, "tnonil") == 0) {
+                                               bb.Tnonil = lv != 0;
+                                       } else if (strcmp(nme, "tdense") == 0) {
+                                               bb.Tdense = lv != 0;
+                                       } else if (strcmp(nme, "size") == 0) {
+                                               if (lv > (lng) BUN_MAX)
+                                                       throw(MAL, 
"remote.bincopyfrom",
+                                                                 "bad %s 
value: %s", nme, val);
+                                               bb.size = (BUN) lv;
+                                       } else if (strcmp(nme, "tailsize") == 
0) {
+                                               bb.tailsize = (size_t) lv;
+                                       } else if (strcmp(nme, "theapsize") == 
0) {
+                                               bb.theapsize = (size_t) lv;
+                                       } else {
                                                throw(MAL, "remote.bincopyfrom",
-                                                         "bad %s value: %s", 
nme, val);
-                                       bb.size = (BUN) lv;
-                               } else if (strcmp(nme, "tailsize") == 0) {
-                                       bb.tailsize = (size_t) lv;
-                               } else if (strcmp(nme, "theapsize") == 0) {
-                                       bb.theapsize = (size_t) lv;
-                               } else {
-                                       throw(MAL, "remote.bincopyfrom",
-                                                       "unknown element: %s", 
nme);
+                                                         "unknown element: 
%s", nme);
+                                       }
                                }
                                nme = val = NULL;
                                break;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to