public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] What is wrong with this program ?
Date: Tue, 28 Apr 2020 11:52:22 +0200	[thread overview]
Message-ID: <20200428095222.GC6221@yuki.lan> (raw)
In-Reply-To: <20200428094745.io5fni2txzl6n37q@vireshk-i7>

Hi!
> #include "tst_test.h"
> 
> static void run(void)
> {
> 	int fd;
> 
> 	fd = SAFE_OPEN("file", O_RDWR | O_CREAT);
> 	SAFE_CLOSE(fd);
> 	fd = SAFE_OPEN("file", O_RDWR | O_CREAT);
> }
> 
> static struct tst_test test = {
> 	.test_all = run,
> 	.needs_tmpdir = 1,
> };
> 
> 
> It fails with:
> 
> safe_macros.c:230: BROK: foo.c:9: open(file,66,01) failed: EACCES (13)
> 
> if run as a normal user and passes with sudo.

I guess that you forget to pass the mode argument to the first
SAFE_OPEN() and hence the second one fails because the garbage passed to
mode prevents normal users from opening the file.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-04-28  9:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  9:47 [LTP] What is wrong with this program ? Viresh Kumar
2020-04-28  9:52 ` Cyril Hrubis [this message]
2020-04-28 10:02   ` Viresh Kumar
2020-04-28 10:09     ` Martin Doucha
2020-04-28 11:49     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200428095222.GC6221@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox