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.
This commit is contained in:
Jim Meyering committed 2014-12-20 18:51:52 -08:00
1 parent 9eb391523b
commit 311d11269e
3 files changed
+4 -5

No files matched your search

-1
View File
@@ -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
+2 -2
View File
@@ -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. */
}
+2 -2
View File
@@ -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;
}
}