| 1 | From 28067b88ad91e794675734bc92bd9c8653b4a46a Mon Sep 17 00:00:00 2001 |
| 2 | Message-ID: <28067b88ad91e794675734bc92bd9c8653b4a46a.1709973702.git.vivien@planete-kraus.eu> |
| 3 | From: Vivien Kraus <[email protected]> |
| 4 | Date: Sat, 9 Mar 2024 09:36:56 +0100 |
| 5 | Subject: [PATCH] corba-loc: Do not allocate more tokens than necessary. |
| 6 | |
| 7 | To split the list of locations, the code calls g_strsplit with the |
| 8 | last argument set to G_MAXINT. It means that g_strsplit will try to |
| 9 | allocate a huge array (G_MAXINT + 1, for the final NULL), mostly |
| 10 | filled with NULL. Unfortunately, on 32-bit systems, this is one past |
| 11 | the authorized length for an array. Previous versions of glib would |
| 12 | not care, but the new version now raises an error if this happens. |
| 13 | |
| 14 | To get an array of the appropriate size, we can just pass -1 to the |
| 15 | last argument. |
| 16 | |
| 17 | * src/orb/orb-core/corba-loc.c (ORBit_corbaloc_parse): Replace |
| 18 | G_MAXINT with -1. |
| 19 | |
| 20 | src/orb/orb-core/corba-loc.c | 2 +- |
| 21 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 22 | |
| 23 | diff --git a/src/orb/orb-core/corba-loc.c b/src/orb/orb-core/corba-loc.c |
| 24 | index abfcaa29..6492d392 100644 |
| 25 | |
| 26 | |
| 27 | ORBit_corbaloc_parse (const gchar *corbaloc) |
| 28 | if (!(objkey = orbit_url_decode (okey))) |
| 29 | goto ret_error; |
| 30 | |
| 31 | - if (!(token = g_strsplit (loc, ",", G_MAXINT))) |
| 32 | + if (!(token = g_strsplit (loc, ",", -1))) |
| 33 | goto ret_error; |
| 34 | |
| 35 | /* [ 'iiop' ] ':' [ '//' ] [ version '@' ] host [ ':' port ] */ |
| 36 | |
| 37 | base-commit: 144be2e9860286c83f009e7689250e0af977cc5e |
| 38 | -- |
| 39 | 2.41.0 |
| 40 |