[PATCH xf86-video-qxl 5/5] spiceqxl_audio: fix possible buffer overflow (clang)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've tested this. Previously strncat was used incorrectly, it is
replaced with snprintf per Uri's suggestion.

Signed-off-by: Alon Levy <alevy@xxxxxxxxxx>
---
 src/spiceqxl_audio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/spiceqxl_audio.c b/src/spiceqxl_audio.c
index 3cd80ff..5b87302 100644
--- a/src/spiceqxl_audio.c
+++ b/src/spiceqxl_audio.c
@@ -167,9 +167,9 @@ scan_fifos (struct audio_data *data, const char *dirname)
             return 0;
         }
 
-        strncpy(path, dirname, sizeof(path));
-        strncat(path, "/", sizeof(path));
-        strncat(path, ent->d_name, sizeof(path));
+        if (snprintf(path, sizeof(path), "%s/%s", dirname, ent->d_name) >= sizeof(path)) {
+            ErrorF("playback: FIFO filename is too long - truncated into %s", path);
+        }
 
         data->fifo_fds[i] = open(path, O_RDONLY | O_RSYNC | O_NONBLOCK);
         if (data->fifo_fds[i] < 0)
-- 
1.8.3.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]