shell bypass 403

Cubjrnet7 Shell


name : string_view.h
/**
@file     string_view.h
@brief    String View
@details  Copyright (c) 2024 Acronis
@author   Denis Kopyrin ([email protected])
@since    $Id: $
*/

#pragma once

#ifndef BPF_PROGRAM
#include <linux/types.h>
#include <linux/string.h>
#endif
#ifdef KERNEL_MOCK
#include <mock/mock.h>
#endif

typedef struct
{
	const char* str;
	size_t len;
} string_view_t;

#define STRING_VIEW_CONST(str) { str, sizeof(str) - 1 }

static inline void string_view_init_empty(string_view_t* sv)
{
	sv->str = NULL;
	sv->len = 0;
}

static inline void string_view_init(string_view_t* sv, const char* str, size_t len)
{
	sv->str = str;
	sv->len = len;
}

static inline bool string_view_empty(const string_view_t* sv)
{
	return 0 == sv->len;
}

static inline bool string_view_equal(const string_view_t* sv0, const string_view_t* sv1)
{
	if (sv0->len != sv1->len)
		return false;

	return 0 == __builtin_memcmp(sv0->str, sv1->str, sv0->len);
}

static inline void string_view_advance(string_view_t *sv, unsigned int amount)
{
	if (amount > sv->len)
		amount = sv->len;

	sv->len -= amount;
	sv->str += amount;
}

static inline bool string_view_starts_with(const string_view_t* sv, const string_view_t* prefix)
{
	if (prefix->len > sv->len)
		return false;

	return 0 == __builtin_memcmp(sv->str, prefix->str, prefix->len);
}

© 2025 Cubjrnet7