compositor-drm: Ensure strings from EDID blobs are null terminated

strncpy only adds null terminating bytes if the source string is smaller
than the destination string.  Since this function relies on the string
being null terminated when checking its contents, we better make sure
there is at least a \0 as the last character.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
dev
Bryce Harrington 9 years ago
parent e54cee17a7
commit 9c7de167f8
  1. 3
      src/compositor-drm.c

@ -1933,6 +1933,9 @@ edid_parse_string(const uint8_t *data, char text[])
* terminated or not junk. */ * terminated or not junk. */
strncpy(text, (const char *) data, 12); strncpy(text, (const char *) data, 12);
/* guarantee our new string is null-terminated */
text[12] = '\0';
/* remove insane chars */ /* remove insane chars */
for (i = 0; text[i] != '\0'; i++) { for (i = 0; text[i] != '\0'; i++) {
if (text[i] == '\n' || if (text[i] == '\n' ||

Loading…
Cancel
Save