Messages in this thread | | | Date | Tue, 17 Nov 2009 12:25:03 +0000 | From | Pádraig Brady <> | Subject | Re: [PATCH] Documentation: Fix NUL termination of strncpy |
| |
Roel Kluin wrote: > Ensure the copied strings are NUL terminated. > > Signed-off-by: Roel Kluin <roel.kluin@gmail.com> > --- >> Rationale (please correct me if I'm wrong): > > diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c > index 6e25c26..4d71b0e 100644 > --- a/Documentation/accounting/getdelays.c > +++ b/Documentation/accounting/getdelays.c > @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) > err(1, "Invalid rcv buf size\n"); > break; > case 'm': > - strncpy(cpumask, optarg, sizeof(cpumask)); > + strncpy(cpumask, optarg, sizeof(cpumask) - 1);
You need to explicitly NUL terminate strncpy(): http://www.pixelbeat.org/programming/gcc/string_buffers.html
cheers, Pádraig. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |