summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-01-26 01:02:37 +0000
committermidipix <writeonce@midipix.org>2024-01-26 03:16:39 +0000
commite1a2b14c1354a74d498349fb2afc3fcaa4d7259c (patch)
treecb516154ffcdb0caba09a2bdfa4b65c29946f3ce /src
parent0fad1cf6fceebe40e86b5320860b9c45848aa3e4 (diff)
downloadmdso-e1a2b14c1354a74d498349fb2afc3fcaa4d7259c.tar.bz2
mdso-e1a2b14c1354a74d498349fb2afc3fcaa4d7259c.tar.xz
argv.h: argv_show_error(): gracefully handle vendor-specific (-W) arguments.
Diffstat (limited to 'src')
-rw-r--r--src/internal/argv/argv.h27
-rw-r--r--src/internal/perk/perk_structs.h2
2 files changed, 25 insertions, 4 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 973983a..2b53179 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -1,6 +1,6 @@
/****************************************************************************/
/* argv.h: a thread-safe argument vector parser and usage screen generator */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************************/
@@ -83,6 +83,7 @@ enum argv_error {
ARGV_ERROR_INTERNAL,
ARGV_ERROR_SHORT_OPTION,
ARGV_ERROR_LONG_OPTION,
+ ARGV_ERROR_VENDOR_OPTION,
ARGV_ERROR_OPTARG_NONE,
ARGV_ERROR_OPTARG_REQUIRED,
ARGV_ERROR_OPTARG_PARADIGM,
@@ -398,7 +399,11 @@ static void argv_scan(
fval = ch;
}
} else {
- ferr = ARGV_ERROR_SHORT_OPTION;
+ if ((ch == &parg[0][1]) && (ch[0] == 'W') && ch[1]) {
+ ferr = ARGV_ERROR_VENDOR_OPTION;
+ } else {
+ ferr = ARGV_ERROR_SHORT_OPTION;
+ }
}
} else if (!fnoscan && (fhybrid || is_long_option(ch))) {
@@ -531,7 +536,10 @@ static const char * argv_program_name(const char * program_path)
static void argv_show_error(int fd, struct argv_ctx * ctx)
{
- char opt_short_name[2] = {0,0};
+ char * ch;
+ char * cap;
+ char opt_vendor_buf[256];
+ char opt_short_name[2] = {0,0};
if (ctx->erropt && ctx->erropt->short_name)
opt_short_name[0] = ctx->erropt->short_name;
@@ -547,6 +555,19 @@ static void argv_show_error(int fd, struct argv_ctx * ctx)
argv_dprintf(fd,"'--%s' is not a valid long option\n",ctx->errch);
break;
+ case ARGV_ERROR_VENDOR_OPTION:
+ memset(opt_vendor_buf,0,sizeof(opt_vendor_buf));
+ strncpy(opt_vendor_buf,ctx->errch,sizeof(opt_vendor_buf) - 1);
+
+ cap = &opt_vendor_buf[sizeof(opt_vendor_buf)];
+
+ for (ch=opt_vendor_buf; ch && *ch && ch<cap; ch++)
+ if ((*ch == '=') || (*ch == ',') || (*ch == ':'))
+ *ch = '\0';
+
+ argv_dprintf(fd,"'-%s' is not a valid vendor option\n",opt_vendor_buf);
+ break;
+
case ARGV_ERROR_OPTARG_NONE:
argv_dprintf(fd,"'%s' is not a valid option value for [%s%s%s%s%s] "
"(option values may not be specified)\n",
diff --git a/src/internal/perk/perk_structs.h b/src/internal/perk/perk_structs.h
index 4dd2ffc..eed16f2 100644
--- a/src/internal/perk/perk_structs.h
+++ b/src/internal/perk/perk_structs.h
@@ -332,7 +332,7 @@ struct pe_raw_coff_symbol_name {
struct pe_raw_coff_strtbl {
unsigned char cst_size [0x04]; /* 0x00 */
- unsigned char cst_data[]; /* 0x04 */
+ unsigned char cst_data [0x01]; /* 0x04 */
};