mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 18:20:10 +01:00
Previously, we would allocate a buffer of the worst case, that is, 4 times the number of bytes, in case all of them require octal escaping. Coverity doesn't like _escape_ansic() for another reason: Error: NULL_RETURNS (CWE-476): [#def298] NetworkManager-1.31.5/src/core/settings/plugins/ifcfg-rh/shvar.c:161: returned_null: "g_malloc" returns "NULL". NetworkManager-1.31.5/src/core/settings/plugins/ifcfg-rh/shvar.c:161: alias: Assigning: "q" = "dest = g_malloc(strlen(source) * 4UL + 1UL + 3UL)". Both pointers are now "NULL". NetworkManager-1.31.5/src/core/settings/plugins/ifcfg-rh/shvar.c:163: dereference: Incrementing a pointer which might be null: "q". # 161| q = dest = g_malloc(strlen(source) * 4 + 1 + 3); # 162| # 163|-> *q++ = '$'; # 164| *q++ = '\''; # 165| It doesn't recognize that g_malloc() shouldn't return NULL (because we never request zero bytes). I am not sure how to avoid that, but let's rework the code to first count how many characters we exactly need. It think that should also help with the coverity warning. Doing exact allocation requires first to count the number of required bytes. It still might be worth it, because we might keep the allocated strings a bit longer around. |
||
|---|---|---|
| .. | ||
| plugins | ||
| nm-agent-manager.c | ||
| nm-agent-manager.h | ||
| nm-secret-agent.c | ||
| nm-secret-agent.h | ||
| nm-settings-connection.c | ||
| nm-settings-connection.h | ||
| nm-settings-plugin.c | ||
| nm-settings-plugin.h | ||
| nm-settings-storage.c | ||
| nm-settings-storage.h | ||
| nm-settings-utils.c | ||
| nm-settings-utils.h | ||
| nm-settings.c | ||
| nm-settings.h | ||