Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  lsm_set_self_attr_test.c

  Sprache: C
 

// SPDX-License-Identifier: GPL-2.0
/*
 * Linux Security Module infrastructure tests
 * Tests for the lsm_set_self_attr system call
 *
 * Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
 */


#define _GNU_SOURCE
#include <linux/lsm.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include "../kselftest_harness.h"
#include "common.h"

TEST(ctx_null_lsm_set_self_attr)
{
 ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT, NULL,
     sizeof(struct lsm_ctx), 0));
}

TEST(size_too_small_lsm_set_self_attr)
{
 const long page_size = sysconf(_SC_PAGESIZE);
 struct lsm_ctx *ctx = calloc(page_size, 1);
 __u32 size = page_size;

 ASSERT_NE(NULL, ctx);
 if (attr_lsm_count()) {
  ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size,
            0));
 }
 ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT, ctx, 10));

 free(ctx);
}

TEST(flags_zero_lsm_set_self_attr)
{
 const long page_size = sysconf(_SC_PAGESIZE);
 struct lsm_ctx *ctx = calloc(page_size, 1);
 __u32 size = page_size;

 ASSERT_NE(NULL, ctx);
 if (attr_lsm_count()) {
  ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size,
            0));
 }
 ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT, ctx, size, 1));

 free(ctx);
}

TEST(flags_overset_lsm_set_self_attr)
{
 const long page_size = sysconf(_SC_PAGESIZE);
 struct lsm_ctx *ctx = calloc(page_size, 1);
 __u32 size = page_size;

 ASSERT_NE(NULL, ctx);
 if (attr_lsm_count()) {
  ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size,
            0));
 }
 ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT | LSM_ATTR_PREV, ctx,
     size, 0));

 free(ctx);
}

TEST_HARNESS_MAIN

Messung V0.5 in Prozent
C=96 H=93 G=94

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik