summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Heller <hellerda@linux.vnet.ibm.com>2018-06-19 13:29:16 -0400
committerDave Heller <hellerda@linux.vnet.ibm.com>2018-06-19 13:29:16 -0400
commit34a805505ec75e65a6882403d582b845a50a62ad (patch)
treebe9f82c3bbe5882557c9787fd8687163619b3130
parent4d5f1063ab3e5460f71002f2395808f03caa0a3e (diff)
downloadsb-signing-utils-34a805505ec75e65a6882403d582b845a50a62ad.tar.gz
sb-signing-utils-34a805505ec75e65a6882403d582b845a50a62ad.zip
Fix a few BEAM warnings
Signed-off-by: Dave Heller <hellerda@linux.vnet.ibm.com>
-rw-r--r--container.c12
-rw-r--r--print-container.c3
2 files changed, 8 insertions, 7 deletions
diff --git a/container.c b/container.c
index 5bcc4a2..0708cd8 100644
--- a/container.c
+++ b/container.c
@@ -48,7 +48,7 @@ int close_fds()
{
for (int fd = 3; fd < 16; fd++) {
int fd_test = dup(fd);
- if (fd_test > 0) {
+ if (fd_test >= 0) {
close(fd_test);
close(fd);
}
@@ -96,7 +96,6 @@ void debug_print(char *lead, unsigned char *buffer, size_t buflen)
* - len = 0 means validate input of arbitrary length.
*/
int isValidHex(char *input, int len) {
- int r;
size_t maxlen = 512; // sane limit
regex_t regexpr;
char pattern[48];
@@ -113,10 +112,10 @@ int isValidHex(char *input, int len) {
sprintf(pattern, "^(0x|0X)?[a-fA-F0-9]%s$", multiplier);
- if ((r = regcomp(&regexpr, pattern, REG_EXTENDED | REG_NOSUB)))
+ if ((regcomp(&regexpr, pattern, REG_EXTENDED | REG_NOSUB)))
die(EX_SOFTWARE, "%s", "failure to compile regex");
- if (!(r = regexec(&regexpr, input, 0, NULL, 0)))
+ if (!(regexec(&regexpr, input, 0, NULL, 0)))
result = true;
regfree(&regexpr);
@@ -130,7 +129,6 @@ int isValidHex(char *input, int len) {
* - NOTE: not all ascii chars are allowed here.
*/
int isValidAscii(char *input, int len) {
- int r;
size_t maxlen = 256; // sane limit
regex_t regexpr;
char pattern[48];
@@ -147,10 +145,10 @@ int isValidAscii(char *input, int len) {
sprintf(pattern, "^[a-zA-Z0-9_+-]%s$", multiplier);
- if ((r = regcomp(&regexpr, pattern, REG_EXTENDED | REG_NOSUB)))
+ if ((regcomp(&regexpr, pattern, REG_EXTENDED | REG_NOSUB)))
die(EX_SOFTWARE, "%s", "failure to compile regex");
- if (!(r = regexec(&regexpr, input, 0, NULL, 0)))
+ if (!(regexec(&regexpr, input, 0, NULL, 0)))
result = true;
regfree(&regexpr);
diff --git a/print-container.c b/print-container.c
index ea84b62..678b919 100644
--- a/print-container.c
+++ b/print-container.c
@@ -502,6 +502,9 @@ static bool getPayloadHash(int fdin, uint64_t pl_sz_expected, unsigned char *md)
static bool getVerificationHash(char *input, unsigned char *md, int len)
{
+ if (len < 0)
+ die(EX_NOINPUT, "%s", "Expected len > 0");
+
char buf[len * 2 + 1 + 2]; // allow trailing \n and leading "0x"
char *p;
OpenPOWER on IntegriCloud