- char fullname[strlen(scriptname) + strlen(pathext)];
- char *ext = fullname + strlen(scriptname);
- strcpy(fullname, scriptname);
+ size_t pathlen = strlen(pathext);
+ size_t scriptlen = strlen(scriptname);
+ char fullname[scriptlen + pathlen + 1];
+ char *ext = fullname + scriptlen;
+ strncpy(fullname, scriptname, sizeof fullname);