Skip to content

Commit f3d3981

Browse files
committed
progressbar: Ensure buffers are large enough for string manipulation
1 parent f6a0512 commit f3d3981

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/core/linux/SDL_progressbar.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,23 @@ static char *GetDBUSObjectPath(void)
4949

5050
// Ensure it starts with a letter or underscore
5151
if (!SDL_isalpha(app_id[0]) && app_id[0] != '_') {
52+
app_id = SDL_realloc(app_id, SDL_strlen(app_id) + 2);
53+
if (!app_id) {
54+
return NULL;
55+
}
5256
SDL_memmove(app_id + 1, app_id, SDL_strlen(app_id) + 1);
5357
app_id[0] = '_';
5458
}
5559

5660
// Create full path
57-
char path[1024];
58-
SDL_snprintf(path, sizeof(path), "/org/libsdl/%s_%d", app_id, getpid());
61+
char *path;
62+
if (SDL_asprintf(&path, "/org/libsdl/%s_%d", app_id, getpid()) < 0) {
63+
path = NULL;
64+
}
5965

6066
SDL_free(app_id);
6167

62-
return SDL_strdup(path);
68+
return path;
6369
}
6470

6571
static char *GetAppDesktopPath(void)

0 commit comments

Comments
 (0)