[PATCH] address conversions



While working on my reader.c patch for the ifcfg-fedora plugin, I've noticed that there are large number of inet_XtoY() calls that are not necessarily correct. In addition, inet_aton() and inet_ntoa() are used. It's better practice to use inet_pton() and inet_ntop() even if you are doing an IPv4 conversion.

Attached is a patch to fix the following issues:

1) Replacing all inet_aton() uses with inet_pton() with error checking.
2) Replacing all inet_ntoa() uses with inet_ntop() with error checking.
3) Make sure the return values are checked on existing inet_pton() usage. I noticed inconsistent usage of this function. A non-zero return value from inet_pton() does not indicate success. Success is >0, failure is <=0. 4) Make sure the return values are checked on existing inet_ntop() usage. A NULL return value indicates failure.

I did not scan around the code much surrounding these function calls. I followed functionality that made sense for the usage I saw, which for the most part meant using nm_warning() and continuing (and storing a NULL for failed string conversions).

On a side note, I noticed a lot of instances of ip4_address_to_string() all over the code (sometimes called ip_address_to_string). Might be a candidate for libnm-util.

Attachment: NetworkManager-address-conversion.patch
Description: Binary data




--
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]