Skip to content

Commit 5799d9e

Browse files
meyeringairlied
authored andcommitted
drm/nouveau/pm: don't read/write beyond end of stack buffer
NUL-terminate after strncpy. If the parameter "profile" has length 16 or more, then strncpy leaves "string" with no NUL terminator, so the following search for '\n' may read beyond the end of that 16-byte buffer. If it finds a newline there, then it will also write beyond the end of that stack buffer. Signed-off-by: Jim Meyering <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 5edaad8 commit 5799d9e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/gpu/drm/nouveau/nouveau_pm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ nouveau_pm_profile_set(struct drm_device *dev, const char *profile)
235235
return -EPERM;
236236

237237
strncpy(string, profile, sizeof(string));
238+
string[sizeof(string) - 1] = 0;
238239
if ((ptr = strchr(string, '\n')))
239240
*ptr = '\0';
240241

0 commit comments

Comments
 (0)