clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkrc-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/capplets/common -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -D CAFECC_DATA_DIR="/usr/share/cafe-control-center" -D CAFELOCALEDIR="/usr/share/locale" -D CTK_ENGINE_DIR="/usr/lib/x86_64-linux-gnu/ctk-3.0/3.0.0/theming-engines" -D G_LOG_DOMAIN="capplet-common" -D INSTALL_PREFIX="/usr" -I ../.. -I ../../libwindow-settings -D PIXMAP_DIR="/usr/share/cafe-control-center/pixmaps" -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/libxml2 -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/cafe-desktop-2.0 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/croma-1 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-settings-daemon -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/capplets/common -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-06-112840-113088-1 -x c ctkrc-utils.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | #ifdef HAVE_CONFIG_H |
23 | #include <config.h> |
24 | #endif |
25 | |
26 | #include <string.h> |
27 | #include <unistd.h> |
28 | #include <glib.h> |
29 | #include <glib/gstdio.h> |
30 | #include <fcntl.h> |
31 | #include <ctk/ctk.h> |
32 | |
33 | #define INCLUDE_SYMBOL ((gpointer) 1) |
34 | #define ENGINE_SYMBOL ((gpointer) 2) |
35 | #define COLOR_SCHEME_SYMBOL ((gpointer) 3) |
36 | |
37 | gchar* ctkrc_find_named(const gchar* name) |
38 | { |
39 | |
40 | |
41 | |
42 | gchar* path = NULL; |
43 | const gchar* home_dir; |
44 | const gchar* subpath = "ctk-2.0" G_DIR_SEPARATOR_S "ctkrc"; |
45 | |
46 | |
47 | |
48 | home_dir = g_get_home_dir(); |
49 | |
50 | if (home_dir) |
51 | { |
52 | path = g_build_filename(home_dir, ".themes", name, subpath, NULL); |
53 | |
54 | if (!g_file_test (path, G_FILE_TEST_EXISTS)) |
55 | { |
56 | g_free (path); |
57 | path = NULL; |
58 | } |
59 | } |
60 | |
61 | if (!path) |
62 | { |
63 | const gchar * const * dirs = g_get_system_data_dirs(); |
64 | |
65 | if (dirs != NULL) |
66 | for (; !path && *dirs != NULL; ++dirs) |
67 | { |
68 | path = g_build_filename(*dirs, "themes", name, subpath, NULL); |
69 | |
70 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
71 | { |
72 | g_free (path); |
73 | path = NULL; |
74 | } |
75 | } |
76 | } |
77 | |
78 | return path; |
79 | |
80 | } |
81 | |
82 | void ctkrc_get_details(gchar* filename, GSList** engines, GSList** symbolic_colors) |
83 | { |
84 | gint file = -1; |
85 | GSList* files = NULL; |
86 | GSList* read_files = NULL; |
87 | GTokenType token; |
88 | GScanner *scanner = g_scanner_new (NULL); |
89 | |
90 | g_scanner_scope_add_symbol (scanner, 0, "include", INCLUDE_SYMBOL); |
91 | |
92 | if (engines != NULL) |
| 1 | Assuming 'engines' is equal to NULL | |
|
| |
93 | { |
94 | g_scanner_scope_add_symbol (scanner, 0, "engine", ENGINE_SYMBOL); |
95 | } |
96 | |
97 | files = g_slist_prepend (files, g_strdup (filename)); |
98 | |
99 | while (files != NULL) |
| 3 | | Assuming 'files' is not equal to NULL | |
|
| 4 | | Loop condition is true. Entering loop body | |
|
100 | { |
101 | filename = files->data; |
102 | files = g_slist_delete_link (files, files); |
103 | |
104 | if (filename == NULL) |
| 5 | | Assuming 'filename' is not equal to NULL | |
|
| |
105 | continue; |
106 | |
107 | if (g_slist_find_custom (read_files, filename, (GCompareFunc) strcmp)) |
| 7 | | Assuming the condition is false | |
|
| |
108 | { |
109 | g_warning ("Recursion in the ctkrc detected!"); |
110 | g_free (filename); |
111 | continue; |
112 | } |
113 | |
114 | read_files = g_slist_prepend (read_files, filename); |
115 | |
116 | file = g_open (filename, O_RDONLY); |
117 | if (file == -1) |
| 9 | | Assuming the condition is false | |
|
| |
118 | { |
119 | g_warning ("Could not open file \"%s\"", filename); |
120 | } |
121 | else |
122 | { |
123 | g_scanner_input_file (scanner, file); |
124 | while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF) |
| 11 | | Assuming the condition is true | |
|
| 12 | | Loop condition is true. Entering loop body | |
|
125 | { |
126 | GTokenType string_token; |
127 | if (token == '@') |
| 13 | | Assuming the condition is false | |
|
| |
128 | { |
129 | if (symbolic_colors == NULL) |
130 | continue; |
131 | token = g_scanner_get_next_token (scanner); |
132 | if (token != G_TOKEN_IDENTIFIER) |
133 | continue; |
134 | if (!g_slist_find_custom (*symbolic_colors, scanner->value.v_identifier, (GCompareFunc) strcmp)) |
135 | *symbolic_colors = g_slist_append (*symbolic_colors, g_strdup (scanner->value.v_identifier)); |
136 | continue; |
137 | } |
138 | |
139 | if (token != G_TOKEN_SYMBOL) |
| 15 | | Assuming 'token' is equal to G_TOKEN_SYMBOL | |
|
| |
140 | continue; |
141 | |
142 | if (scanner->value.v_symbol == INCLUDE_SYMBOL) |
| 17 | | Assuming field 'v_symbol' is not equal to INCLUDE_SYMBOL | |
|
| |
143 | { |
144 | string_token = g_scanner_get_next_token (scanner); |
145 | if (string_token != G_TOKEN_STRING) |
146 | continue; |
147 | if (g_path_is_absolute (scanner->value.v_string)) |
148 | { |
149 | files = g_slist_prepend (files, g_strdup (scanner->value.v_string)); |
150 | } |
151 | else |
152 | { |
153 | gchar *basedir = g_path_get_dirname (filename); |
154 | files = g_slist_prepend (files, g_build_path (G_DIR_SEPARATOR_S, basedir, scanner->value.v_string, NULL)); |
155 | g_free (basedir); |
156 | } |
157 | } |
158 | else if (scanner->value.v_symbol == ENGINE_SYMBOL) |
| 19 | | Assuming field 'v_symbol' is equal to ENGINE_SYMBOL | |
|
| |
159 | { |
160 | string_token = g_scanner_get_next_token (scanner); |
161 | if (string_token != G_TOKEN_STRING || scanner->value.v_string[0] == '\0') |
| 21 | | Assuming 'string_token' is equal to G_TOKEN_STRING | |
|
| 22 | | Assuming the condition is false | |
|
| |
162 | continue; |
163 | if (!g_slist_find_custom (*engines, scanner->value.v_string, (GCompareFunc) strcmp)) |
| 24 | | Dereference of null pointer (loaded from variable 'engines') |
|
164 | *engines = g_slist_append (*engines, g_strdup (scanner->value.v_string)); |
165 | } |
166 | |
167 | } |
168 | close (file); |
169 | } |
170 | } |
171 | |
172 | g_slist_foreach (read_files, (GFunc) g_free, NULL); |
173 | g_slist_free (read_files); |
174 | |
175 | g_scanner_destroy (scanner); |
176 | } |
177 | |
178 | |
179 | gchar * |
180 | ctkrc_get_color_scheme (const gchar *ctkrc_file) |
181 | { |
182 | gint file = -1; |
183 | gchar *result = NULL; |
184 | GSList *files = NULL; |
185 | GSList *read_files = NULL; |
186 | GTokenType token; |
187 | GScanner *scanner = ctk_rc_scanner_new (); |
188 | |
189 | g_scanner_scope_add_symbol (scanner, 0, "include", INCLUDE_SYMBOL); |
190 | g_scanner_scope_add_symbol (scanner, 0, "ctk_color_scheme", COLOR_SCHEME_SYMBOL); |
191 | g_scanner_scope_add_symbol (scanner, 0, "ctk-color-scheme", COLOR_SCHEME_SYMBOL); |
192 | |
193 | files = g_slist_prepend (files, g_strdup (ctkrc_file)); |
194 | while (files != NULL) |
195 | { |
196 | gchar *filename = files->data; |
197 | files = g_slist_delete_link (files, files); |
198 | |
199 | if (filename == NULL) |
200 | continue; |
201 | |
202 | if (g_slist_find_custom (read_files, filename, (GCompareFunc) strcmp)) |
203 | { |
204 | g_warning ("Recursion in the ctkrc detected!"); |
205 | g_free (filename); |
206 | continue; |
207 | } |
208 | |
209 | read_files = g_slist_prepend (read_files, filename); |
210 | |
211 | file = g_open (filename, O_RDONLY); |
212 | if (file == -1) |
213 | { |
214 | g_warning ("Could not open file \"%s\"", filename); |
215 | } |
216 | else |
217 | { |
218 | g_scanner_input_file (scanner, file); |
219 | while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF) |
220 | { |
221 | if (GINT_TO_POINTER (token) == COLOR_SCHEME_SYMBOL) |
222 | { |
223 | if (g_scanner_get_next_token (scanner) == '=') |
224 | { |
225 | token = g_scanner_get_next_token (scanner); |
226 | if (token == G_TOKEN_STRING) |
227 | { |
228 | g_free (result); |
229 | result = g_strdup (scanner->value.v_string); |
230 | } |
231 | } |
232 | } |
233 | } |
234 | close (file); |
235 | } |
236 | } |
237 | |
238 | g_slist_foreach (read_files, (GFunc) g_free, NULL); |
239 | g_slist_free (read_files); |
240 | |
241 | g_scanner_destroy (scanner); |
242 | return result; |
243 | } |
244 | |
245 | gchar* ctkrc_get_color_scheme_for_theme(const gchar* theme_name) |
246 | { |
247 | |
248 | gchar* ctkrc_file; |
249 | gchar* scheme = NULL; |
250 | |
251 | ctkrc_file = ctkrc_find_named(theme_name); |
252 | |
253 | if (ctkrc_file) |
254 | { |
255 | scheme = ctkrc_get_color_scheme(ctkrc_file); |
256 | g_free(ctkrc_file); |
257 | } |
258 | |
259 | return scheme; |
260 | } |