Skip to contentSkip to conversation

drm: etnaviv: fix strncpy sizeof argument

PATCH In review Bo YU 1 participant 2 messages Mar 28, 2019 – Apr 2, 2019

Subsystems (2)
lore
Share & tools
lore

Bo YU

author
#0 lore raw

PATCH v2 1/1 drm: etnaviv: fix strncpy sizeof argument

Calling strncpy with a maximum size argument of 64 bytes on destination array "domain->name" of size 64 bytes might leave the destination string unterminated.

Detected by CoverityScan, CID# 1443992: Memory - illegal accesses (BUFFER_SIZE_WARNING)

Fixes 9e2c2e2730126 (drm/etnaviv: add infrastructure to query perf counter)

---
v2: accroding to Russell's suggestion, replace strncpy with strlcpy

---
 drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +1 -1
index 4227a4006c34..ce178f23e86a 100644
@@ -414,7 +414,7 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu,
 
 	domain->id = domain->iter;
 	domain->nr_signals = dom->nr_signals;
-	strncpy(domain->name, dom->name, sizeof(domain->name));
+	strlcpy(domain->name, dom->name, sizeof(domain->name));
 
 	domain->iter++;
 	if (domain->iter == meta->nr_domains)
Signature · 1 line
2.11.0
author
#1 lore raw
Quoted 29 lines · Bo YU

Calling strncpy with a maximum size argument of 64 bytes on destination array "domain->name" of size 64 bytes might leave the destination string unterminated.

Detected by CoverityScan, CID# 1443992: Memory - illegal accesses (BUFFER_SIZE_WARNING)

Fixes 9e2c2e2730126 (drm/etnaviv: add infrastructure to query perf counter)

---
v2: accroding to Russell's suggestion, replace strncpy with strlcpy

---
 drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +1 -2
index 4227a4006c34..ce178f23e86a 100644
@@ -414,7 +414,7 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu,
 
        domain->id = domain->iter;
        domain->nr_signals = dom->nr_signals;
-       strncpy(domain->name, dom->name, sizeof(domain->name));
+       strlcpy(domain->name, dom->name, sizeof(domain->name));
 
        domain->iter++;
        if (domain->iter == meta->nr_domains)
--
Quoted 2 lines

2.11.0

Ping?