ctdb-daemon: Validate length of new interface names
authorMartin Schwenke <martin@meltin.net>
Fri, 18 Mar 2016 09:41:45 +0000 (20:41 +1100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Mar 2016 23:23:20 +0000 (00:23 +0100)
Interface names that are too long will be truncated by strncpy(3)
later on.  It is better to validate the length of each new interface
name to ensure it will be usable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/server/ctdb_takeover.c

index b3660ab6044a358e51ab7e08af3a9bbdc80e62c1..4adbb1184370ea493adf48181ec8fa5421d3290c 100644 (file)
@@ -68,6 +68,11 @@ static int ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
 {
        struct ctdb_interface *i;
 
+       if (strlen(iface) > CTDB_IFACE_SIZE) {
+               DEBUG(DEBUG_ERR, ("Interface name too long \"%s\"\n", iface));
+               return -1;
+       }
+
        /* Verify that we don't have an entry for this ip yet */
        for (i=ctdb->ifaces;i;i=i->next) {
                if (strcmp(i->name, iface) == 0) {