|
Packit |
6e6f77 |
/* fileread.h - Offset checking routines for file reading
|
|
Packit |
6e6f77 |
*
|
|
Packit |
6e6f77 |
* Copyright (C) 1998 Oskar Liljeblad
|
|
Packit |
6e6f77 |
*
|
|
Packit |
6e6f77 |
* This program is free software: you can redistribute it and/or modify
|
|
Packit |
6e6f77 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
6e6f77 |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
6e6f77 |
* (at your option) any later version.
|
|
Packit |
6e6f77 |
*
|
|
Packit |
6e6f77 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
6e6f77 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6e6f77 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
6e6f77 |
* GNU General Public License for more details.
|
|
Packit |
6e6f77 |
*
|
|
Packit |
6e6f77 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
6e6f77 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
6e6f77 |
*/
|
|
Packit |
6e6f77 |
|
|
Packit |
6e6f77 |
#ifndef FILEREAD_H
|
|
Packit |
6e6f77 |
#define FILEREAD_H
|
|
Packit |
6e6f77 |
|
|
Packit |
6e6f77 |
#include <stdbool.h> /* POSIX/Gnulib */
|
|
Packit |
6e6f77 |
#include "common/common.h"
|
|
Packit |
6e6f77 |
|
|
Packit |
6e6f77 |
#define RETURN_IF_BAD_POINTER(r, x) \
|
|
Packit |
6e6f77 |
if (!check_offset(fi->memory, fi->total_size, fi->name, &(x), sizeof(x))) { \
|
|
Packit |
6e6f77 |
/*printf("bad_pointer in %s:%d\n", __FILE__, __LINE__);*/ \
|
|
Packit |
6e6f77 |
return (r); \
|
|
Packit |
6e6f77 |
}
|
|
Packit |
6e6f77 |
#define RETURN_IF_BAD_OFFSET(r, x, s) \
|
|
Packit |
6e6f77 |
if (!check_offset(fi->memory, fi->total_size, fi->name, x, s)) { \
|
|
Packit |
6e6f77 |
/*printf("bad_offset in %s:%d\n", __FILE__, __LINE__);*/ \
|
|
Packit |
6e6f77 |
return (r); \
|
|
Packit |
6e6f77 |
}
|
|
Packit |
6e6f77 |
|
|
Packit |
6e6f77 |
bool check_offset(const char *, size_t, const char *, const void *, size_t);
|
|
Packit |
6e6f77 |
|
|
Packit |
6e6f77 |
#endif
|