mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 00:30:32 +01:00
shared: improve length check in nm_construct_name_a()
Refactor the check so that integer overflow cannot happen. Realistically, it anyway couldn't happen, because _name is nowhere near the size of G_MAXSIZE. Still, avoid such code. Also, the operands involved here are constants, so the extra check can anyway be resolved at compile-time.
This commit is contained in:
parent
648c256b90
commit
39bd412d28
1 changed files with 2 additions and 1 deletions
|
|
@ -1420,7 +1420,8 @@ nm_decode_version (guint version, guint *major, guint *minor, guint *micro)
|
|||
char *_buf2; \
|
||||
\
|
||||
nm_assert (_p_val_to_free && !*_p_val_to_free); \
|
||||
if (NM_STRLEN (format) + _name_len < 200) \
|
||||
if ( NM_STRLEN (format) < 200 \
|
||||
&& _name_len < (gsize) (200 - NM_STRLEN (format))) \
|
||||
_buf2 = nm_sprintf_bufa (NM_STRLEN (format) + _name_len, format, _name); \
|
||||
else { \
|
||||
_buf2 = g_strdup_printf (format, _name); \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue