[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Li
From: |
R. Bernstein |
Subject: |
Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux |
Date: |
Tue, 28 Nov 2006 15:08:02 -0500 |
Okay - thanks.
Burkhard Plaum writes:
> Burkhard Plaum wrote:
> > R. Bernstein wrote:
> >
> >> First, thanks for changing those strcpy's to strncpy.
> >>
> >> Am I missing something or would "PATH_MAX" better be "len" below?
> >> else {
> >> tmp_dst[len] = '\0';
> >> strncpy(tmp_src, tmp_dst, PATH_MAX);
> >> }
> >
> >
> > It's because (according to manpage) readlink adds no
> > '\0' to the string and instead returns the length (len in this case).
>
> Ahh, sorry, I misread your mail:
> I think in this case, even strcpy would be save, since len is the
> return value from readlink and cannot be larger than PATH_MAX in our
> case (otherwise, readlink() would be broken).
>
> Using
>
> strncpy(tmp_src, tmp_dst, len);
>
> would be wrong, since we don't copy the final '\0' then. So we should use:
>
> strncpy(tmp_src, tmp_dst, len+1);
>
> But I really believe, that it doesn't really matter in this case
>
> Burkhard
>
>
> _______________________________________________
> Libcdio-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/libcdio-devel
>
- [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, (continued)
- [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, R. Bernstein, 2006/11/20
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, plaum, 2006/11/21
- Message not available
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, plaum, 2006/11/27
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, R. Bernstein, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, Burkhard Plaum, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, R. Bernstein, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, Burkhard Plaum, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, R. Bernstein, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, Burkhard Plaum, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux, Burkhard Plaum, 2006/11/28
- Re: [Libcdio-devel] [Patch] More bullet-proof drive detection for GNU/Linux,
R. Bernstein <=