[SSSD] [PATCH] User home directories management

Martin Nagy mnagy at redhat.com
Thu Oct 22 17:53:47 UTC 2009


On Thu, 2009-10-22 at 19:48 +0200, Jakub Hrozek wrote:
> > A more serious bug I see in files.c:
> > +    while ((cnt = read(ifd, buf, sizeof(buf))) > 0) {
> > +        while (cnt > 0) {
> > +            written = write(ofd, buf, (size_t)cnt);
> > +            if (written == -1) {
> > +                ret = errno;
> > +                DEBUG(1, ("Cannot write() to source file '%s': [%d][%
> > s].\n",
> > +                            dst, ret, strerror(ret)));
> > +                goto fail;
> > +            }
> > +            cnt -= written;
> > +        }
> > +    }
> > 
> > You should write like this:
> > written = write(ofd, buf + written, cnt);
> 
> Fixed, although a little differently than you proposed

Right, because I had a bug there too. Sigh, code like this is always
prone to errors. Thanks for your work.

Ack.

Martin




More information about the sssd-devel mailing list