Off-by-one overflow (?)

2012-09-03 Thread rustyBSD
/usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? In an use like this: strncpy(a, b, sizeof(a)); the null terminator will be added beyond the end of a if b has the same size (or a larger size). Should use something

Re: Off-by-one overflow (?)

2012-09-03 Thread bert
On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? In an use like this: strncpy(a, b, sizeof(a)); the null terminator will be added beyond the end of a

Re: Off-by-one overflow (?)

2012-09-03 Thread Otto Moerbeek
On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? In an use like this: strncpy(a, b, sizeof(a)); No, this is not an overflow. But a will potentieally

Re: Off-by-one overflow (?)

2012-09-03 Thread rustyBSD
Le 03/09/2012 16:46, bert a écrit : On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? No i'm wrong, but it's still better to use strlcpy In an use like this:

Re: Off-by-one overflow (?)

2012-09-03 Thread Kenneth R Westerback
On Mon, Sep 03, 2012 at 05:18:52PM +0200, rustyBSD wrote: Le 03/09/2012 16:46, bert a ?crit : On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? No i'm

Re: Off-by-one overflow (?)

2012-09-03 Thread Otto Moerbeek
On Mon, Sep 03, 2012 at 05:19:44PM +0200, Otto Moerbeek wrote: On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ? In an use like this:

Re: Off-by-one overflow (?)

2012-09-03 Thread rustyBSD
Le 03/09/2012 22:22, Otto Moerbeek a écrit : On Mon, Sep 03, 2012 at 05:19:44PM +0200, Otto Moerbeek wrote: On Mon, Sep 03, 2012 at 04:37:42PM +0200, rustyBSD wrote: /usr/src/sbin/disklabel/disklabel.c lines: 333 1092 1096 Is this me, or these strncpy() may cause off-by-one overflows ?