Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/gen_pfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ static int _gen_pfc_arch(const struct db_filter_col *col,
*/
int gen_pfc_generate(const struct db_filter_col *col, int fd)
{
int newfd;
int newfd, rc = 0;
unsigned int iter;
FILE *fds;

Expand Down Expand Up @@ -508,8 +508,10 @@ int gen_pfc_generate(const struct db_filter_col *col, int fd)
fprintf(fds, "# pseudo filter code end\n");
fprintf(fds, "#\n");

fflush(fds);
fclose(fds);
if (fflush(fds) < 0)
rc = -errno;
if (fclose(fds) < 0 && rc == 0)
rc = -errno;

return 0;
return rc;
}
13 changes: 12 additions & 1 deletion tests/11-basic-basic_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
*/

#include <errno.h>
#include <fcntl.h>
#include <unistd.h>

#include <seccomp.h>

int main(int argc, char *argv[])
{
int rc;
int fd, rc;
scmp_filter_ctx ctx;
uint32_t attr;
unsigned int api;
Expand Down Expand Up @@ -159,6 +160,16 @@ int main(int argc, char *argv[])
rc = seccomp_export_pfc(ctx, sysconf(_SC_OPEN_MAX) - 1);
if (rc != -ECANCELED)
return -1;
rc = seccomp_attr_set(ctx, SCMP_FLTATR_API_SYSRAWRC, 1);
if (rc != 0)
return -1;
fd = open("/dev/full", O_WRONLY);
if (fd < 0)
return -1;
rc = seccomp_export_pfc(ctx, fd);
close(fd);
if (rc != -ENOSPC)
return -1;
}
seccomp_release(ctx);
ctx = NULL;
Expand Down