aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-03-10 10:23:26 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-03-11 14:15:36 -0500
commitd89dba7a275f40757d27ba16c8bc6aa424656bbe (patch)
treec42b16fc568b9ffdb0458b59c6112f9eb9f24792
parent23952ec92850bcdc91b8167fa95ec05dd59a80ea (diff)
libertas: fix write past end of array in mesh_id_get()
defs.meshie.val.mesh_id is 32 chars long. It's not supposed to be NUL terminated. This code puts a terminator on the end to make it easier to print to sysfs. The problem is that if the mesh_id fills the entire buffer the original code puts the terminator one spot past the end. The way the original code was written, there was a check to make sure that maxlen was less than PAGE_SIZE. Since we know that maxlen is at most 34 chars, I just removed the check. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/libertas/mesh.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index acf3bf63ee33..9d097b9c8005 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -918,7 +918,6 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
918 char *buf) 918 char *buf)
919{ 919{
920 struct mrvl_mesh_defaults defs; 920 struct mrvl_mesh_defaults defs;
921 int maxlen;
922 int ret; 921 int ret;
923 922
924 ret = mesh_get_default_parameters(dev, &defs); 923 ret = mesh_get_default_parameters(dev, &defs);
@@ -931,13 +930,11 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
931 defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN; 930 defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
932 } 931 }
933 932
934 /* SSID not null terminated: reserve room for \0 + \n */ 933 memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len);
935 maxlen = defs.meshie.val.mesh_id_len + 2; 934 buf[defs.meshie.val.mesh_id_len] = '\n';
936 maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE; 935 buf[defs.meshie.val.mesh_id_len + 1] = '\0';
937 936
938 defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0'; 937 return defs.meshie.val.mesh_id_len + 1;
939
940 return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
941} 938}
942 939
943/** 940/**