trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hzel...@apache.org
Subject [3/4] incubator-trafodion git commit: add more checking logic, espcially for buffer overrun
Date Wed, 27 Jul 2016 20:29:37 GMT
add more checking logic, espcially for buffer overrun


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/effe7b84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/effe7b84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/effe7b84

Branch: refs/heads/master
Commit: effe7b849c432cba9447c75ff89285e433832c60
Parents: d282505
Author: Liu Ming <ovis_poly@sina.com>
Authored: Wed Jul 27 14:42:25 2016 +0000
Committer: Liu Ming <ovis_poly@sina.com>
Committed: Wed Jul 27 14:42:25 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NATable.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/effe7b84/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index b59abd3..098e514 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -87,8 +87,6 @@
 
 #define MAX_NODE_NAME 9
 #define MAX_PRECISION_ALLOWED  18
-#define HIVE_MAX_PRECISION_ALLOWED  38
-#define MAX_SCALE_ALLOWED     6
 #define MAX_NUM_LEN     16
 
 #include "SqlParserGlobals.h"
@@ -3682,8 +3680,8 @@ NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap)
 
   if ( !strncmp(hiveType, "decimal", 7) )
   {
-    Lng32 i=0, pstart=0, pend=0, sstart=0, send=0, p=-1, s = -1;
-    Lng32 hiveTypeLen = strlen(hiveType);
+    Int32 i=0, pstart=-1, pend=-1, sstart=-1, send=-1, p=-1, s = -1;
+    Int32 hiveTypeLen = strlen(hiveType);
     char pstr[MAX_NUM_LEN], sstr[MAX_NUM_LEN];
     memset(pstr,0,sizeof(pstr));
     memset(sstr,0,sizeof(sstr));
@@ -3706,7 +3704,12 @@ NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap)
       else
        continue;
     }
-
+    if(pend == -1) // no comma found, so no sstart and send
+    {
+       pend = send;
+       send = -1;
+       s = 0;
+    }  
     if(pend - pstart > 0)
     {
       if( (pend - pstart) >= MAX_NUM_LEN ) // too long
@@ -3725,14 +3728,14 @@ NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap)
 
     if( (p>0) && (p <= MAX_PRECISION_ALLOWED) ) //have precision between 1
- 18
     {
-      if( ( s >=0 )  &&  ( s<= MAX_SCALE_ALLOWED) ) //have valid scale
+      if( ( s >=0 )  &&  ( s<= p) ) //have valid scale
         return new (heap) SQLDecimal( p, s, TRUE, TRUE);
       else
         return NULL;
     }
-    else if( (p > MAX_PRECISION_ALLOWED)  && ( p <= HIVE_MAX_PRECISION_ALLOWED)
)  
+    else if( p > MAX_PRECISION_ALLOWED)  
     {
-      if ( (s>=0) && ( s< p ) ) //have valid scale
+      if ( (s>=0) && ( s<= p ) ) //have valid scale
         return new (heap) SQLBigNum( p, s, TRUE, TRUE, TRUE, NULL);
       else
         return NULL;


Mime
View raw message