mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 16:29:36 +03:00
make gtk commandline filename loading use snprintf
This commit is contained in:
parent
3a7fb23b87
commit
a73f22c966
10
gtk/gui.c
10
gtk/gui.c
@ -421,13 +421,15 @@ static void gui_init(int argc, char** argv, char **respath)
|
||||
if (argc > 1) {
|
||||
struct stat fs;
|
||||
if (stat(argv[1], &fs) == 0) {
|
||||
size_t addrlen;
|
||||
char *rp = realpath(argv[1], NULL);
|
||||
assert(rp != NULL);
|
||||
addr = malloc(SLEN("file://") + strlen(rp) + /*\0 */ 1);
|
||||
|
||||
/* calculate file url length including terminator */
|
||||
addrlen = SLEN("file://") + strlen(rp) + 1;
|
||||
addr = malloc(addrlen);
|
||||
assert(addr != NULL);
|
||||
/* These are safe thanks to the above sum */
|
||||
strcpy(addr, "file://");
|
||||
strcat(addr, rp);
|
||||
snprintf(addr, addrlen, "file://%s", rp);
|
||||
free(rp);
|
||||
} else {
|
||||
addr = strdup(argv[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user