Some improvements to robust name interface. These API's are safe now by convention, but it is worth providing some safety checks against future bugs.
Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]> --- net/core/dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- net-2.6.19.orig/net/core/dev.c +++ net-2.6.19/net/core/dev.c @@ -636,7 +636,8 @@ struct net_device * dev_get_by_flags(uns */ int dev_valid_name(const char *name) { - return !(*name == '\0' + return !(*name == '\0' + || strlen(name) >= IFNAMSIZ || !strcmp(name, ".") || !strcmp(name, "..") || strchr(name, '/')); @@ -3198,13 +3199,15 @@ struct net_device *alloc_netdev(int size struct net_device *dev; int alloc_size; + BUG_ON(strlen(name) >= sizeof(dev->name)); + /* ensure 32-byte alignment of both the device and private area */ alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST; alloc_size += sizeof_priv + NETDEV_ALIGN_CONST; p = kzalloc(alloc_size, GFP_KERNEL); if (!p) { - printk(KERN_ERR "alloc_dev: Unable to allocate device.\n"); + printk(KERN_ERR "alloc_netdev: Unable to allocate device.\n"); return NULL; } - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html