summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-09 07:40:26 -0400
committermidipix <writeonce@midipix.org>2018-08-09 07:40:26 -0400
commit2b097c305098af71f6b4172540d5ddc1a3848808 (patch)
treeebce2688271069a21694e317a230e71f34333393
parente1a7721fe04ace25388a3438a0d943bb183245bc (diff)
downloadperk-2b097c305098af71f6b4172540d5ddc1a3848808.tar.bz2
perk-2b097c305098af71f6b4172540d5ddc1a3848808.tar.xz
internals: pe_output_strerror(): use strerror_r(3) rather than strerror(3).
-rw-r--r--src/output/pe_output_error.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/output/pe_output_error.c b/src/output/pe_output_error.c
index af23238..aaa8eb0 100644
--- a/src/output/pe_output_error.c
+++ b/src/output/pe_output_error.c
@@ -63,7 +63,9 @@ static const char * pe_output_unit_header(const struct pe_error_info * erri)
return "while parsing";
}
-static const char * pe_output_strerror(const struct pe_error_info * erri)
+static const char * pe_output_strerror(
+ const struct pe_error_info * erri,
+ char (*errbuf)[256])
{
if (erri->eflags & PERK_ERROR_CUSTOM)
return ((erri->elibcode < 0) || (erri->elibcode >= PERK_ERR_CAP))
@@ -80,7 +82,10 @@ static const char * pe_output_strerror(const struct pe_error_info * erri)
return "input error: string length exceeds buffer size.";
else
- return strerror(erri->esyscode);
+ return strerror_r(erri->esyscode,*errbuf,sizeof(*errbuf))
+ ? "internal error: strerror_r(3) call failed"
+ : *errbuf;
+
}
static int pe_output_error_record_plain(
@@ -88,8 +93,10 @@ static int pe_output_error_record_plain(
const struct pe_error_info * erri)
{
const char * epath;
- const char * errdesc = pe_output_strerror(erri);
+ char errbuf[256];
+
int fderr = pe_driver_fderr(dctx);
+ const char * errdesc = pe_output_strerror(erri,&errbuf);
epath = erri->euctx
? *erri->euctx->path
@@ -123,8 +130,10 @@ static int pe_output_error_record_annotated(
const struct pe_error_info * erri)
{
const char * epath;
- const char * errdesc = pe_output_strerror(erri);
+ char errbuf[256];
+
int fderr = pe_driver_fderr(dctx);
+ const char * errdesc = pe_output_strerror(erri,&errbuf);
epath = erri->euctx
? *erri->euctx->path
@@ -170,7 +179,7 @@ static int pe_output_error_record_annotated(
strlen(errdesc) ? ": " : "",
aclr_bold,
- pe_output_strerror(erri),
+ errdesc,
aclr_reset) < 0)
return -1;