Skip to content

Commit ca530d7

Browse files
author
Armin Biere
committed
safe option
1 parent bc21acf commit ca530d7

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

NEWS.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 1.7.2
2+
-------------
3+
4+
- Configuration option `--safe` disables writing to a file
5+
through `popen` which makes library usage safer.
6+
17
Version 1.7.1
28
-------------
39

@@ -8,7 +14,7 @@ Version 1.7.1
814
(worked for user propagator but now also in combination with LRAT);
915
further minor bug fixes.
1016

11-
- Added support for LRAT + external propagator in combination
17+
- Added support for LRAT + external propagator in combination.
1218

1319
Version 1.7.0
1420
-------------

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.1
1+
1.7.2

configure

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ check=no
2222
competition=no
2323
coverage=no
2424
profile=no
25+
safe=no
2526
contracts=yes
2627
tracing=yes
2728
unlocked=yes
@@ -97,6 +98,9 @@ where '<option>' is one of the following
9798
--competition configure for the competition
9899
('--quiet', '--no-contracts', '--no-tracing')
99100
101+
--safe disable writing through 'popen' for more
102+
safe usage of the library in applications
103+
100104
-f... pass '-f<option>[=<val>]' options to the makefile
101105
-m32 pass '-m32' to the compiler (compile for 32 bit)
102106
-ggdb3 pass '-ggdb3' to makefile (like '-s')
@@ -154,6 +158,8 @@ do
154158

155159
--competition) competition=yes;;
156160

161+
--safe) safe=yes;;
162+
157163
--no-unlocked) unlocked=no;;
158164

159165
-m32) options="$options $1";m32=yes;;
@@ -290,6 +296,7 @@ fi
290296

291297
[ $check = no ] && CXXFLAGS="$CXXFLAGS -DNDEBUG"
292298
[ $logging = yes ] && CXXFLAGS="$CXXFLAGS -DLOGGING"
299+
[ $safe = yes ] && CXXFLAGS="$CXXFLAGS -DSAFE"
293300
[ $quiet = yes ] && CXXFLAGS="$CXXFLAGS -DQUIET"
294301
[ $profile = yes ] && CXXFLAGS="$CXXFLAGS -pg"
295302
[ $coverage = yes ] && CXXFLAGS="$CXXFLAGS -ftest-coverage -fprofile-arcs"

src/file.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,16 @@ FILE *File::read_pipe (Internal *internal, const char *fmt, const int *sig,
217217
return open_pipe (internal, fmt, path, "r");
218218
}
219219

220+
#ifndef SAFE
221+
220222
FILE *File::write_pipe (Internal *internal, const char *fmt,
221223
const char *path) {
222224
MSG ("opening pipe to write '%s'", path);
223225
return open_pipe (internal, fmt, path, "w");
224226
}
225227

228+
#endif
229+
226230
/*------------------------------------------------------------------------*/
227231

228232
File *File::read (Internal *internal, FILE *f, const char *n) {
@@ -268,6 +272,7 @@ File *File::read (Internal *internal, const char *path) {
268272
File *File::write (Internal *internal, const char *path) {
269273
FILE *file;
270274
int close_input = 2;
275+
#ifndef SAFE
271276
if (has_suffix (path, ".xz"))
272277
file = write_pipe (internal, "xz -c > %s", path);
273278
else if (has_suffix (path, ".bz2"))
@@ -278,6 +283,7 @@ File *File::write (Internal *internal, const char *path) {
278283
file = write_pipe (internal, "7z a -an -txz -si -so > %s 2>/dev/null",
279284
path);
280285
else
286+
#endif
281287
file = write_file (internal, path), close_input = 1;
282288

283289
return file ? new File (internal, true, close_input, file, path) : 0;

src/file.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ class File {
5353
const char *mode);
5454
static FILE *read_pipe (Internal *, const char *fmt, const int *sig,
5555
const char *path);
56+
#ifndef SAFE
5657
static FILE *write_pipe (Internal *, const char *fmt, const char *path);
58+
#endif
5759

5860
public:
5961
static char *find (const char *prg); // search in 'PATH'

src/version.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#ifdef NBUILD
2626
#ifndef VERSION
27-
#define VERSION "1.7.1"
27+
#define VERSION "1.7.2"
2828
#endif // VERSION
2929
#endif // NBUILD
3030

0 commit comments

Comments
 (0)