summaryrefslogtreecommitdiff
path: root/giscanner/sourcescanner.h
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2022-11-02 20:29:53 +0100
committerEmmanuele Bassi <ebassi@gmail.com>2023-01-08 02:24:39 +0000
commitb37f24b7e27a77c398f41cc331608aff806f0d42 (patch)
tree0c47a5f9e1ce348fd2817ad2d391dc88b32c7001 /giscanner/sourcescanner.h
parent41feafa85d73b4a9dd8eac9dbe1231130bf2c7ca (diff)
downloadgobject-introspection-b37f24b7e27a77c398f41cc331608aff806f0d42.tar.gz
scanner: don't accept invalid symbols in binary expressions
The rules for binary expressions were entirely oblivious to the type of the operand symbols and assumed they're integer constants. This is very unfortunate, since it caused all sort of nonsense to end up getting accepted. One such example is the following define from NetworkManager's libnm: #define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT)) As G_PARAM_USER_SHIFT is unknown, it was parsed as an invalid symbol. The addition didn't care, treated it as: #define NM_SETTING_PARAM_SECRET (1 << (2 + 0)) Let's just ensure we get CSYMBOL_TYPE_CONST only when both operands actually have const_int_set. Otherwise just create CSYMBOL_TYPE_INVALID. That will cause the symbol to be dropped on the floor eventually, but that's probably much better than a having an invalid value.
Diffstat (limited to 'giscanner/sourcescanner.h')
-rw-r--r--giscanner/sourcescanner.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/giscanner/sourcescanner.h b/giscanner/sourcescanner.h
index 40c5fc96..eb2d312f 100644
--- a/giscanner/sourcescanner.h
+++ b/giscanner/sourcescanner.h
@@ -172,6 +172,10 @@ gboolean gi_source_symbol_get_const_boolean (GISourceSymbol *symb
GISourceSymbol * gi_source_symbol_ref (GISourceSymbol *symbol);
void gi_source_symbol_unref (GISourceSymbol *symbol);
GISourceSymbol * gi_source_symbol_copy (GISourceSymbol *symbol);
+GISourceSymbol * gi_source_symbol_const_binary (GISourceSymbol *s1,
+ GISourceSymbol *s2,
+ GFile *file,
+ int line);
/* Private */
void gi_source_scanner_add_symbol (GISourceScanner *scanner,