Break out of an infinite loop. Fixes bugs 392 - 395. Add a UNIX Makefile
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 30 Aug 2005 19:43:32 +0000 (19:43 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 30 Aug 2005 19:43:32 +0000 (19:43 +0000)
for generation of the PRES dissector.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15626 f5534014-38df-0310-8fa8-9805f1628bb7

asn1/pres/Makefile [new file with mode: 0644]
asn1/pres/packet-pres-template.c
epan/dissectors/packet-pres.c
epan/dissectors/packet-pres.h

diff --git a/asn1/pres/Makefile b/asn1/pres/Makefile
new file mode 100644 (file)
index 0000000..e918754
--- /dev/null
@@ -0,0 +1,17 @@
+# $Id: Makefile 15178 2005-08-02 05:21:19Z jmayer $
+
+DISSECTOR_FILES=packet-pres.c packet-pres.h
+
+all: generate_dissector
+
+generate_dissector: $(DISSECTOR_FILES)
+
+$(DISSECTOR_FILES): ../../tools/asn2eth.py ISO8823-PRESENTATION.asn packet-pres-template.c packet-pres-template.h pres.cnf
+       python ../../tools/asn2eth.py -X -b -e -p pres -c pres.cnf -s packet-pres-template ISO8823-PRESENTATION.asn
+
+clean:
+       rm -f parsetab.py $(DISSECTOR_FILES)
+
+copy_files: generate_dissector
+       cp $(DISSECTOR_FILES) ../../epan/dissectors
+
index aca594e85292d6174c912d57d4e1d6734dffacc4..39202beb6b6a9cb72df9a86ad5a1c6dbd03e57a0 100644 (file)
@@ -136,7 +136,7 @@ dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 void
 dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 {
-       int offset = 0;
+       int offset = 0, old_offset;
 /* first, try to check length   */
 /* do we have at least 4 bytes  */
        if (!tvb_bytes_exist(tvb, 0, 4)){
@@ -157,12 +157,11 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
        global_pinfo = pinfo;
 
        while (tvb_reported_length_remaining(tvb, offset) > 0){
-
+               old_offset = offset;
                offset = dissect_ppdu(tvb, offset, pinfo, parent_tree);
-               if(offset == FALSE ){
-                       proto_tree_add_text(parent_tree, tvb, offset, -1,"Internal error");
-                       offset = tvb_length(tvb);
-                       break;
+               if(offset <= old_offset){
+                       proto_tree_add_text(parent_tree, tvb, offset, -1,"Invalid offset");
+                       THROW(ReportedBoundsError);
                }
        }
 }
index d49d7d418cbde75e558dd34a78f2f085b3bcb1a6..986571ff35206d30e2c587203cef451f82a6a164 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-pres.c                                                            */
+/* ./packet-pres.c                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p pres -c pres.cnf -s packet-pres-template ISO8823-PRESENTATION.asn */
 
 /* Input file: packet-pres-template.c */
@@ -1687,7 +1687,7 @@ dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 void
 dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 {
-       int offset = 0;
+       int offset = 0, old_offset;
 /* first, try to check length   */
 /* do we have at least 4 bytes  */
        if (!tvb_bytes_exist(tvb, 0, 4)){
@@ -1708,12 +1708,11 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
        global_pinfo = pinfo;
 
        while (tvb_reported_length_remaining(tvb, offset) > 0){
-
+               old_offset = offset;
                offset = dissect_ppdu(tvb, offset, pinfo, parent_tree);
-               if(offset == FALSE ){
-                       proto_tree_add_text(parent_tree, tvb, offset, -1,"Internal error");
-                       offset = tvb_length(tvb);
-                       break;
+               if(offset <= old_offset){
+                       proto_tree_add_text(parent_tree, tvb, offset, -1,"Invalid offset");
+                       THROW(ReportedBoundsError);
                }
        }
 }
index b1b35692e6f12a4b16bb85e7eb5452f32b51e8a2..1956ea8ada7376ae3b3cd21a34236965a72e695b 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-pres.h                                                            */
+/* ./packet-pres.h                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p pres -c pres.cnf -s packet-pres-template ISO8823-PRESENTATION.asn */
 
 /* Input file: packet-pres-template.h */