Skip to contentSkip to conversation

drivers/video: fsl-diu-fb: fix potential memcpy buffer overflow bug

PATCH Applied Timur Tabi 1 participant 1 message Sep 15, 2011 Framebuffer layer

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 9/13 drivers/video: fsl-diu-fb: fix potential memcpy buffer overflow bug

It makes no sense to limit the size of a strncpy() to the length of the source string.

---
 drivers/video/fsl-diu-fb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fsl-diu-fb.c +1 -1
index 19bfbf5..3776949 100644
@@ -655,7 +655,7 @@ static void set_fix(struct fb_info *info)
 	struct fb_var_screeninfo *var = &info->var;
 	struct mfb_info *mfbi = info->par;
 
-	strncpy(fix->id, mfbi->id, strlen(mfbi->id));
+	strncpy(fix->id, mfbi->id, sizeof(fix->id));
 	fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
 	fix->type = FB_TYPE_PACKED_PIXELS;
 	fix->accel = FB_ACCEL_NONE;
Signature · 1 line
1.7.3.4