On 2015/3/13 20:50, Paolo Bonzini wrote: > > > On 13/03/2015 12:09, Shannon Zhao wrote: >> + g_assert(strlen(path) < sizeof(helper.sun_path)); > > Ok. > >> sockfd = socket(AF_UNIX, SOCK_STREAM, 0); >> if (sockfd < 0) { >> fprintf(stderr, "failed to create socket: %s\n", strerror(errno)); >> return -1; >> } >> - strcpy(helper.sun_path, path); >> + strncpy(helper.sun_path, path, sizeof(helper.sun_path)); > > strcpy is okay here. strncpy makes people think of what happens if > strlen(path) == sizeof(helper.sun_path). While this cannot happen here > because of the assertion, the function should still be used with care. >
Thanks, will fix along with the other patch. -- Thanks, Shannon