dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug? "fstat64(f, &sb) < 0 && S_ISREG(sb.st_mode)"
@ 2016-10-25 15:33 Denys Vlasenko
  2016-10-25 17:13 ` Eduardo Bustamante
  0 siblings, 1 reply; 5+ messages in thread
From: Denys Vlasenko @ 2016-10-25 15:33 UTC (permalink / raw)
  To: Herbert Xu, dash

                /* Take care of noclobber mode. */
                if (Cflag) {
                        fname = redir->nfile.expfname;
                        if (stat64(fname, &sb) < 0) {
                                if ((f = open64(fname,
O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0)
                                        goto ecreate;
                        } else if (!S_ISREG(sb.st_mode)) {
                                if ((f = open64(fname, O_WRONLY, 0666)) < 0)
                                        goto ecreate;
                                if (fstat64(f, &sb) < 0 &&
S_ISREG(sb.st_mode)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
was it meant to be "fstat64(f, &sb) < 0 || S_ISREG(sb.st_mode)" ?

                                        close(f);
                                        errno = EEXIST;
                                        goto ecreate;
                                }
                        } else {
                                errno = EEXIST;
                                goto ecreate;
                        }
                        break;
                }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-27  0:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 15:33 Bug? "fstat64(f, &sb) < 0 && S_ISREG(sb.st_mode)" Denys Vlasenko
2016-10-25 17:13 ` Eduardo Bustamante
2016-10-25 17:19   ` Eduardo Bustamante
2016-10-26 21:43   ` Jilles Tjoelker
2016-10-27  0:35     ` Eduardo Bustamante

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).