projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix buffer overflow reported by John Darrington.
[pspp]
/
src
/
language
/
data-io
/
print.c
diff --git
a/src/language/data-io/print.c
b/src/language/data-io/print.c
index 3c36b98bab9eb918e064f09e43a6907f73c84038..262d5397f460114859ea6f9a48ae3ef7cb165fd8 100644
(file)
--- a/
src/language/data-io/print.c
+++ b/
src/language/data-io/print.c
@@
-22,7
+22,7
@@
#include <stdlib.h>
#include <data/case.h>
#include <stdlib.h>
#include <data/case.h>
-#include <data/
forma
t.h>
+#include <data/
data-ou
t.h>
#include <data/procedure.h>
#include <data/transformations.h>
#include <data/variable.h>
#include <data/procedure.h>
#include <data/transformations.h>
#include <data/variable.h>
@@
-317,7
+317,8
@@
parse_variable_argument (const struct dictionary *dict,
if (lex_is_number () || token == '(')
{
if (lex_is_number () || token == '(')
{
- if (!parse_var_placements (tmp_pool, var_cnt, &formats, &format_cnt))
+ if (!parse_var_placements (tmp_pool, var_cnt, false,
+ &formats, &format_cnt))
return false;
add_space = false;
}
return false;
add_space = false;
}
@@
-345,7
+346,7
@@
parse_variable_argument (const struct dictionary *dict,
struct prt_out_spec *spec;
var = vars[var_idx++];
struct prt_out_spec *spec;
var = vars[var_idx++];
- if (!
check_specifier_width (f, var->width, true
))
+ if (!
fmt_check_width_compat (f, var->width
))
return false;
spec = pool_alloc (trns->pool, sizeof *spec);
return false;
spec = pool_alloc (trns->pool, sizeof *spec);
@@
-362,7
+363,8
@@
parse_variable_argument (const struct dictionary *dict,
that usually contains a period. */
spec->sysmis_as_spaces = (which_formats == WRITE
&& var->type == NUMERIC
that usually contains a period. */
spec->sysmis_as_spaces = (which_formats == WRITE
&& var->type == NUMERIC
- && !fmt_is_binary (spec->format.type));
+ && (fmt_get_category (spec->format.type)
+ != FMT_CAT_BINARY));
ll_push_tail (&trns->specs, &spec->ll);
ll_push_tail (&trns->specs, &spec->ll);
@@
-397,6
+399,7
@@
dump_table (struct print_trns *trns, const struct file_handle *fh)
row = 1;
ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
{
row = 1;
ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
{
+ char fmt_string[FMT_STRING_LEN_MAX + 1];
int width;
switch (spec->type)
{
int width;
switch (spec->type)
{
@@
-408,7
+411,7
@@
dump_table (struct print_trns *trns, const struct file_handle *fh)
case PRT_VAR:
tab_text (t, 0, row, TAB_LEFT, spec->var->name);
tab_text (t, 3, row, TAB_LEFT | TAB_FIX,
case PRT_VAR:
tab_text (t, 0, row, TAB_LEFT, spec->var->name);
tab_text (t, 3, row, TAB_LEFT | TAB_FIX,
- fmt_to_string (&spec->format));
+ fmt_to_string (&spec->format
, fmt_string
));
width = spec->format.w;
break;
default:
width = spec->format.w;
break;
default:
@@
-457,7
+460,7
@@
print_trns_proc (void *trns_, struct ccase *c, casenumber case_num UNUSED)
const union value *input = case_data (c, spec->var->fv);
char *output = ds_put_uninit (&trns->line, spec->format.w);
if (!spec->sysmis_as_spaces || input->f != SYSMIS)
const union value *input = case_data (c, spec->var->fv);
char *output = ds_put_uninit (&trns->line, spec->format.w);
if (!spec->sysmis_as_spaces || input->f != SYSMIS)
- data_out (
output, &spec->format, in
put);
+ data_out (
input, &spec->format, out
put);
else
memset (output, ' ', spec->format.w);
if (spec->add_space)
else
memset (output, ' ', spec->format.w);
if (spec->add_space)