summaryrefslogtreecommitdiff
path: root/nasmlib
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2017-04-17 13:52:19 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2017-04-17 13:56:50 -0700
commit8dc965347ddf9caabacc4ca0441efe3a4ec32af8 (patch)
tree39c561c38dab93e90d70a82a1c6180e1571a15c1 /nasmlib
parent74fa0a736ab769dd07ebe3c98b7e94543b558134 (diff)
downloadnasm-8dc965347ddf9caabacc4ca0441efe3a4ec32af8.tar.gz
rdoff: use nasm-provided safe memory allocation and I/O
We already have abort-on-error memory allocation and I/O operations in nasmlib, so use them for rdoff as well. Delete long-since-obsolete rdoff Mkfiles directory. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'nasmlib')
-rw-r--r--nasmlib/file.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/nasmlib/file.c b/nasmlib/file.c
index 95f3c52a..7552b6fb 100644
--- a/nasmlib/file.c
+++ b/nasmlib/file.c
@@ -33,6 +33,16 @@
#include "file.h"
+void nasm_read(void *ptr, size_t size, FILE *f)
+{
+ size_t n = fread(ptr, 1, size, f);
+ if (ferror(f)) {
+ nasm_fatal(0, "unable to read input: %s", strerror(errno));
+ } else if (n != size || feof(f)) {
+ nasm_fatal(0, "fatal short read on input");
+ }
+}
+
void nasm_write(const void *ptr, size_t size, FILE *f)
{
size_t n = fwrite(ptr, 1, size, f);