2
* Copyright (C) 2014 Sourcefire, Inc.
4
* Authors: Kevin Lin <klin@sourcefire.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
#include "clamav-config.h"
25
#include <openssl/ssl.h>
26
#include <openssl/err.h>
27
#include "libclamav/crypto.h"
31
#include "prtn_intxn.h"
33
static int prtn_intxn_list_is_empty(prtn_intxn_list_t* list)
35
return (list->Head == NULL);
38
int prtn_intxn_list_init(prtn_intxn_list_t* list)
45
int prtn_intxn_list_check(prtn_intxn_list_t* list, unsigned *pitxn, off_t start, size_t size)
47
prtn_intxn_node_t *new_node, *check_node;
52
check_node = list->Head;
53
while (check_node != NULL) {
56
if (start > check_node->Start) {
57
if (check_node->Start+check_node->Size > start) {
62
else if (start < check_node->Start) {
63
if (start+size > check_node->Start) {
73
check_node = check_node->Next;
76
/* allocate new node for partition bounds */
77
new_node = (prtn_intxn_node_t *) cli_malloc(sizeof(prtn_intxn_node_t));
79
cli_dbgmsg("PRTN_INTXN: could not allocate new node for checklist!\n");
80
prtn_intxn_list_free(list);
84
new_node->Start = start;
85
new_node->Size = size;
86
new_node->Next = list->Head;
88
list->Head = new_node;
93
int prtn_intxn_list_free(prtn_intxn_list_t* list)
95
prtn_intxn_node_t *next = NULL;
97
while (!prtn_intxn_list_is_empty(list)) {
98
next = list->Head->Next;