[Commotion-admin] [commotiond] Issue69 (#57)

Josh King notifications at github.com
Thu Dec 5 20:50:44 UTC 2013


> @@ -124,6 +124,27 @@ char *cmd_list_profiles(void *self, char *argv[], int argc) {
>    return ret;
>  }
>  
> +/* Set link local ip */
> +char *cmd_generate_local_ip() {
> +
> +  unsigned char mac[6];
> +  memset(mac, '\0', sizeof(mac));
> +  
> +  char *address = malloc(16 * sizeof(char)); 
> +  memset(address, '\0', sizeof(address));

The 'sizeof' call is not the right way to get this value. It will only return the size of the pointer, not the size of what the pointer points to. Additionally, even if it did, sizeof is a precompiler macro, as such it can only work on types and other statically assigned values. Since 'address' is dynamically assigned, you need to use a function like 'strlen' or 'strnlen' to find the length of it.

---
Reply to this email directly or view it on GitHub:
https://github.com/opentechinstitute/commotiond/pull/57/files#r8144208
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.chambana.net/pipermail/commotion-admin/attachments/20131205/b8459219/attachment.html>


More information about the Commotion-admin mailing list