Attached is a better patch, basicly every occurence of
PG_RETURN_POINTER(0) resulted in a segfault, text input like '1.2.3',
'.' or '' would still fail with the first patch.
The behavior here is comparable to what happens when you use
"'foo'::integer"

-- 
Herwin Weststrate
Quarantainenet BV
--- pgsql-asn1oid-0.0.20100818/asn1oid.c	2010-08-18 17:24:28.000000000 +0200
+++ pgsql-asn1oid-0.0.20100818.patched/asn1oid.c	2016-04-29 08:55:12.952143426 +0200
@@ -101,21 +101,36 @@
             tmp[i] += 9;
             break;
         case '.':
-            if(c == str)
-                PG_RETURN_POINTER(0);
+            if(c == str) {
+                if (c[1]) {
+                    /* Skip over first dot */
+                    break;
+                }
+                ereport(ERROR,
+                  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+                  errmsg("invalid input syntax for type asn1oid: \"%s\"",
+                    str)));
+            }
             ++i;
             if(i >= 64)
-                PG_RETURN_POINTER(0);
+                ereport(ERROR,
+                  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+                  errmsg("invalid input syntax for type asn1oid: \"%s\"",
+                    str)));
             tmp[i] = 0;
             break;
         default:
-            PG_RETURN_POINTER(0);
+            ereport(ERROR,
+              (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+              errmsg("invalid input syntax for type asn1oid: \"%s\"",
+                str)));
         }
     }
-    if(c == str)
-        PG_RETURN_POINTER(0);
-    if(c[-1] == '.')
-        PG_RETURN_POINTER(0);
+    if(c == str || c[-1] == '.')
+        ereport(ERROR,
+          (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+          errmsg("invalid input syntax for type asn1oid: \"%s\"",
+            str)));
 
     ++i;
 

Reply via email to