summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2014-12-08 21:19:18 -0800
committerJim Meyering <meyering@fb.com>2014-12-20 18:51:52 -0800
commit311d11269eebf7a869c585e44ae703eb21707ff5 (patch)
treec61a94f19c3aa88cf2fb26fb073cf6076006ff05
parent9eb391523bc0646d9f0e3d943ed18aad4d60b096 (diff)
downloadsed-311d11269eebf7a869c585e44ae703eb21707ff5.tar.gz
maint: enable sc_prohibit_strncpy check
* cfg.mk (exclude_file_name_regexp--sc_prohibit_strncpy): Remove its exemption. * sed/compile.c (compile_program): Remove two misuses of strncpy; use memcpy instead. * sed/execute.c (do_list): Likewise, for one instance.
-rw-r--r--cfg.mk1
-rw-r--r--sed/compile.c4
-rw-r--r--sed/execute.c4
3 files changed, 4 insertions, 5 deletions
diff --git a/cfg.mk b/cfg.mk
index e0316c6..8c46421 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -31,7 +31,6 @@ local-checks-to-skip = \
sc_prohibit_atoi_atof \
sc_prohibit_magic_number_exit \
sc_prohibit_strcmp \
- sc_prohibit_strncpy \
sc_texinfo_acronym \
sc_unmarked_diagnostics \
sc_useless_cpp_parens
diff --git a/sed/compile.c b/sed/compile.c
index 3b9264b..cd86dc4 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -1272,7 +1272,7 @@ compile_program(struct vector *vector)
/* Set the i-th source character. */
trans_pairs[2 * i] = MALLOC(src_lens[i] + 1, char);
- strncpy(trans_pairs[2 * i], src_buf, src_lens[i]);
+ memcpy(trans_pairs[2 * i], src_buf, src_lens[i]);
trans_pairs[2 * i][src_lens[i]] = '\0';
src_buf += src_lens[i]; /* Forward to next character. */
@@ -1286,7 +1286,7 @@ compile_program(struct vector *vector)
/* Set the i-th destination character. */
trans_pairs[2 * i + 1] = MALLOC(mbclen + 1, char);
- strncpy(trans_pairs[2 * i + 1], dest_buf + idx, mbclen);
+ memcpy(trans_pairs[2 * i + 1], dest_buf + idx, mbclen);
trans_pairs[2 * i + 1][mbclen] = '\0';
idx += mbclen; /* Forward to next character. */
}
diff --git a/sed/execute.c b/sed/execute.c
index c839451..8ef4246 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -1523,8 +1523,8 @@ execute_program(struct vector *vec, struct input *input)
line.length += move_offset;
idx += move_offset;
}
- strncpy(line.active + prev_idx, trans[2*i+1],
- trans_len);
+ memcpy(line.active + prev_idx, trans[2*i+1],
+ trans_len);
break;
}
}