> -----Original Message----- > From: Petr Kulhavy [mailto:br...@jikos.cz] > Sent: Tuesday, May 16, 2017 7:57 AM > To: linuxptp-devel@lists.sourceforge.net > Subject: [Linuxptp-devel] [PATCH] clock: fix possible buffer overrun > > This is not a fix of an actual issue rather than prevention of a potential > issue. > On two places a fixed array size (different to the actual size) is used in > snprintf. > Replace with sizeof(array) > > Signed-off-by: Petr Kulhavy <br...@jikos.cz>
Makes sense to me. Thanks, Jake > --- > clock.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/clock.c b/clock.c > index 629a160..b6afba9 100644 > --- a/clock.c > +++ b/clock.c > @@ -1053,7 +1053,7 @@ struct clock *clock_create(enum clock_type type, struct > config *config, > c->utc_timescale = 1; > } > } else if (phc_index >= 0) { > - snprintf(phc, 31, "/dev/ptp%d", phc_index); > + snprintf(phc, sizeof(phc), "/dev/ptp%d", phc_index); > c->clkid = phc_open(phc); > if (c->clkid == CLOCK_INVALID) { > pr_err("Failed to open %s: %m", phc); > @@ -1589,7 +1589,7 @@ int clock_switch_phc(struct clock *c, int phc_index) > clockid_t clkid; > char phc[32]; > > - snprintf(phc, 31, "/dev/ptp%d", phc_index); > + snprintf(phc, sizeof(phc), "/dev/ptp%d", phc_index); > clkid = phc_open(phc); > if (clkid == CLOCK_INVALID) { > pr_err("Switching PHC, failed to open %s: %m", phc); > -- > 2.7.4 > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Linuxptp-devel mailing list > Linuxptp-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxptp-devel ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel