From e6e537524979dde434af3e0b0d5eba6d115a406c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 1 Apr 2014 13:00:33 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift_drm_c.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/blueshift_drm_c.c b/src/blueshift_drm_c.c index 8888146..ad6569c 100644 --- a/src/blueshift_drm_c.c +++ b/src/blueshift_drm_c.c @@ -76,14 +76,13 @@ void blueshift_drm_close(void) */ int blueshift_drm_card_count(void) { - long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10; - char* pathname = alloca(maxlen * sizeof(char)); + char pathname[4096]; int count = 0; struct stat _attr; for (;;) { - sprintf(pathname, DRM_DEV_NAME, DRM_DIR_NAME, count); + snprintf(pathname, 4096, DRM_DEV_NAME, DRM_DIR_NAME, count); if (stat(pathname, &_attr)) break; count++; @@ -101,12 +100,11 @@ int blueshift_drm_card_count(void) */ int blueshift_drm_open_card(int card_index) { - long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10; - char* pathname = alloca(maxlen * sizeof(char)); + char pathname[4096]; int fd; int rc; - sprintf(pathname, DRM_DEV_NAME, DRM_DIR_NAME, card_index); + snprintf(pathname, 4096, DRM_DEV_NAME, DRM_DIR_NAME, card_index); fd = open(pathname, O_RDWR | O_CLOEXEC); if (fd < 0) -- cgit v1.2.3-70-g09d2