Thrift-1377: abort PHP deserialization on unknown field type
authorJake Farrell <jfarrell@apache.org>
Fri, 7 Oct 2011 00:17:25 +0000 (00:17 +0000)
committerJake Farrell <jfarrell@apache.org>
Fri, 7 Oct 2011 00:17:25 +0000 (00:17 +0000)
client: php
Patch: Dave Watson

Previously the code incorrectly ignored unknown field types. After
reading the field header, if it was an unknown type it would incorrectly
assume there was no data, and start trying to read the next field
immediately.

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1179907 13f79535-47bb-0310-9956-ffa450edef68

lib/php/src/protocol/TProtocol.php

index ac1facd..239648e 100644 (file)
@@ -262,7 +262,8 @@ abstract class TProtocol {
         return $result;
       }
     default:
-      return 0;
+      throw new TProtocolException('Unknown field type: '.$type,
+                                   TProtocolException::INVALID_DATA);
     }
   }
 
@@ -356,7 +357,8 @@ abstract class TProtocol {
         return $result;
       }
     default:
-      return 0;
+      throw new TProtocolException('Unknown field type: '.$type,
+                                   TProtocolException::INVALID_DATA);
     }
   }
 }