[openssl-dev] [openssl.org #4070] OpenSSL 1.0.1p bug and suggested fix: su-filter.pl regex for struct/union definitions also matches other code

Ellinger, Wesley M via RT rt at openssl.org
Mon Oct 5 20:34:58 UTC 2015


The su-filter.pl script used for code reformatting in OpenSSL 1.0.1p has a regex that is looking for the start of a struct or union definition.  It is supposed to match code similar to the following:
struct identifier {

However, to match the identifier it is using [^\s]+ which also matches characters that are not valid in identifiers.  For example, it will also match code similar to the following.  This can result in the rest of the file being truncated.
if (foo = OPENSSL_malloc(sizeof(struct identifier))) {

One possible fix is attached.

Wesley Ellinger
HP


-------------- next part --------------
--- prev/su-filter.pl	2015-03-19 09:02:02.000000000 -0500
+++ su-filter.pl	2015-10-02 15:11:11.815000953 -0500
@@ -47,7 +47,7 @@
             do_output($out);
             $in_su = 0;
         }
-    } elsif($incomm <= 0 && /( *)(static )?(const )?(union|struct) ([^\s]+ )?\{/) {
+    } elsif($incomm <= 0 && /( *)(static )?(const )?(union|struct) ([0-9a-zA-Z_]+ )?\{/) {
         $in_su = 1;
         $indent = $1;
         $out = $_;
-------------- next part --------------
_______________________________________________
openssl-bugs-mod mailing list
openssl-bugs-mod at openssl.org
https://mta.openssl.org/mailman/listinfo/openssl-bugs-mod


More information about the openssl-dev mailing list