Skip to content

Commit

Permalink
FUSE - change strcpy to strncpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Liryna committed Apr 4, 2018
1 parent a2db8e1 commit bfccd62
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dokan_fuse/src/fuse_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ int fuse_opt_add_opt(char **opts, const char *opt)
if (!*opts)
newopts = STRDUP(opt);
else {
size_t oldlen = strlen(*opts);
newopts = (char *)realloc(*opts, oldlen + 1 + strlen(opt) + 1);
size_t oldlen = strlen(*opts);
size_t newlen = oldlen + 1 + strlen(opt) + 1;
newopts = (char *)realloc(*opts, newlen);
if (newopts) {
newopts[oldlen] = ',';
strcpy(newopts + oldlen + 1, opt);
strncpy(newopts + oldlen + 1, opt, newlen);
}
}
if (!newopts)
Expand Down Expand Up @@ -222,17 +223,19 @@ static int process_opt_sep_arg(struct fuse_opt_context *ctx,
int res;
char *newarg;
char *param;
size_t newarglen;

if (next_arg(ctx, arg) == -1)
return -1;

param = ctx->argv[ctx->argctr];
newarg = (char *)malloc(sep + strlen(param) + 1);
newarglen = sep + strlen(param) + 1;
newarg = (char *)malloc(newarglen);
if (!newarg)
return alloc_failed();

memcpy(newarg, arg, sep);
strcpy(newarg + sep, param);
strncpy(newarg + sep, param, newarglen);
res = process_opt(ctx, opt, sep, newarg, iso);
free(newarg);

Expand Down

0 comments on commit bfccd62

Please sign in to comment.