platform: fix return value for nm_platform_sysctl_set()
When comparing an unsigned and a signed integer, the signed integer is promoted to unsigned, resulting in a very large number. See the checks "nwrote < len - 1", where nwrote might be -1 to indicate failure. The condition would not be TRUE due to promoting -1 to the max int value. Hence, sysctl_set() was rather wrong.
This commit is contained in:
@@ -2934,7 +2934,7 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
int fd, tries;
|
||||
gssize nwrote;
|
||||
gsize len;
|
||||
gssize len;
|
||||
char *actual;
|
||||
gs_free char *actual_free = NULL;
|
||||
int errsv;
|
||||
@@ -2989,6 +2989,7 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat
|
||||
* about to write.
|
||||
*/
|
||||
len = strlen (value) + 1;
|
||||
nm_assert (len > 0);
|
||||
if (len > 512)
|
||||
actual = actual_free = g_malloc (len + 1);
|
||||
else
|
||||
|
Reference in New Issue
Block a user