Skip to content

Commit

Permalink
Fixed BUFFER_SIZE_WARNING issues introduced by remote images code.
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Bruno <rbruno@gsd.inesc-id.pt>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
  • Loading branch information
Rodrigo Bruno authored and avagin committed Jun 20, 2017
1 parent 9c4921c commit 524fa5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions criu/img-remote-proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ static struct rimage *new_remote_image(char *path, char *snapshot_id)
return NULL;
}

strncpy(rimg->path, path, PATHLEN);
strncpy(rimg->snapshot_id, snapshot_id, PATHLEN);
strncpy(rimg->path, path, PATHLEN -1 );
rimg->path[PATHLEN - 1] = '\0';
strncpy(rimg->snapshot_id, snapshot_id, PATHLEN - 1);
rimg->snapshot_id[PATHLEN - 1] = '\0';
rimg->size = 0;
buf->nbytes = 0;
INIT_LIST_HEAD(&(rimg->buf_head));
Expand Down
3 changes: 2 additions & 1 deletion criu/img-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ struct snapshot *new_snapshot(char *snapshot_id)
pr_perror("Failed to allocate snapshot structure");
return NULL;
}
strncpy(s->snapshot_id, snapshot_id, PATHLEN);
strncpy(s->snapshot_id, snapshot_id, PATHLEN - 1);
s->snapshot_id[PATHLEN - 1]= '\0';
return s;
}

Expand Down

0 comments on commit 524fa5f

Please sign in to comment.