[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/2] libxl: fix -Werror=stringop-truncation in libxl__prepare_sockaddr_un
On Wed, Aug 19, 2020 at 04:00:36AM +0200, Marek Marczykowski-G??recki wrote: > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c > index f360f5e228..b039143b8a 100644 > --- a/tools/libxl/libxl_utils.c > +++ b/tools/libxl/libxl_utils.c > } > memset(un, 0, sizeof(struct sockaddr_un)); > un->sun_family = AF_UNIX; > - strncpy(un->sun_path, path, sizeof(un->sun_path)); > + strncpy(un->sun_path, path, sizeof(un->sun_path) - 1); > return 0; > } While the earlier lines are okay, this line introduces an error. If the compiler complains once the earlier lines are fixed, something might need to be done about this. I would be tempted to switch to strlcpy() since this doesn't look like it needs un->sun_path to be zeroed out. (note I'm not familiar with this code, so someone else needs to check me on this) -- (\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | ehem+sigmsg@xxxxxxx PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |