V4L/DVB (8837): dvb: fix I2C adapters name size
authorJean Delvare <khali@linux-fr.org>
Wed, 3 Sep 2008 20:12:23 +0000 (17:12 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 3 Sep 2008 21:37:50 +0000 (18:37 -0300)
Some DVB drivers are incorrectly assuming that the size of
i2c_adapter.name is I2C_NAME_SIZE.  Here's a fix.

Also change strncpy to strlcpy, as the former is error-prone (and was
indeed incorrectly used.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Uwe Bugla <uwe.bugla@gmx.de>
Reviewed-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/b2c2/flexcop-i2c.c
drivers/media/dvb/frontends/cx24123.c
drivers/media/dvb/frontends/s5h1420.c

index 55973eaf371180d90534bced637142582e5373bc..43a112ec6d44f146b260c64cf12446d036e1283a 100644 (file)
@@ -221,12 +221,12 @@ int flexcop_i2c_init(struct flexcop_device *fc)
        fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM;
        fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER;
 
-       strncpy(fc->fc_i2c_adap[0].i2c_adap.name,
-               "B2C2 FlexCop I2C to demod", I2C_NAME_SIZE);
-       strncpy(fc->fc_i2c_adap[1].i2c_adap.name,
-               "B2C2 FlexCop I2C to eeprom", I2C_NAME_SIZE);
-       strncpy(fc->fc_i2c_adap[2].i2c_adap.name,
-               "B2C2 FlexCop I2C to tuner", I2C_NAME_SIZE);
+       strlcpy(fc->fc_i2c_adap[0].i2c_adap.name, "B2C2 FlexCop I2C to demod",
+               sizeof(fc->fc_i2c_adap[0].i2c_adap.name));
+       strlcpy(fc->fc_i2c_adap[1].i2c_adap.name, "B2C2 FlexCop I2C to eeprom",
+               sizeof(fc->fc_i2c_adap[1].i2c_adap.name));
+       strlcpy(fc->fc_i2c_adap[2].i2c_adap.name, "B2C2 FlexCop I2C to tuner",
+               sizeof(fc->fc_i2c_adap[2].i2c_adap.name));
 
        i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]);
        i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]);
index 386bd7472b9c1c386c476224d306f964e4aac9ab..7156157cb34b2ec9f06c9af3b17e14e84d460f82 100644 (file)
@@ -1072,8 +1072,8 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
     if (config->dont_use_pll)
        cx24123_repeater_mode(state, 1, 0);
 
-       strncpy(state->tuner_i2c_adapter.name,
-               "CX24123 tuner I2C bus", I2C_NAME_SIZE);
+       strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus",
+               sizeof(state->tuner_i2c_adapter.name));
        state->tuner_i2c_adapter.class     = I2C_CLASS_TV_DIGITAL,
        state->tuner_i2c_adapter.algo      = &cx24123_tuner_i2c_algo;
        state->tuner_i2c_adapter.algo_data = NULL;
index 720ed9ff7c5fda6a43b0b5074e16ee28c487eaf0..747d3fa2e5e5c47721a187858bb79c629aea9387 100644 (file)
@@ -915,7 +915,8 @@ struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config,
        state->frontend.demodulator_priv = state;
 
        /* create tuner i2c adapter */
-       strncpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus", I2C_NAME_SIZE);
+       strlcpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus",
+               sizeof(state->tuner_i2c_adapter.name));
        state->tuner_i2c_adapter.class     = I2C_CLASS_TV_DIGITAL,
        state->tuner_i2c_adapter.algo      = &s5h1420_tuner_i2c_algo;
        state->tuner_i2c_adapter.algo_data = NULL;