mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
use a local str_nlen fct instead of hinting to POSIX
This commit is contained in:
parent
a3415da519
commit
2ccf84f40a
4 changed files with 18 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// asn.1 dumping
|
// asn.1 dumping
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#define _POSIX_C_SOURCE 200809L // need for strnlen()
|
|
||||||
#include "asn1dump.h"
|
#include "asn1dump.h"
|
||||||
|
|
||||||
#include "commonutil.h" // ARRAYLEN
|
#include "commonutil.h" // ARRAYLEN
|
||||||
|
@ -344,17 +344,17 @@ static void asn1_tag_dump_object_id(const struct tlv *tlv, const struct asn1_tag
|
||||||
} else {
|
} else {
|
||||||
const char *ppstr = NULL;
|
const char *ppstr = NULL;
|
||||||
mbedtls_oid_get_attr_short_name(&asn1_buf, &ppstr);
|
mbedtls_oid_get_attr_short_name(&asn1_buf, &ppstr);
|
||||||
if (ppstr && strnlen(ppstr, 1)) {
|
if (ppstr && str_nlen(ppstr, 1)) {
|
||||||
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mbedtls_oid_get_sig_alg_desc(&asn1_buf, &ppstr);
|
mbedtls_oid_get_sig_alg_desc(&asn1_buf, &ppstr);
|
||||||
if (ppstr && strnlen(ppstr, 1)) {
|
if (ppstr && str_nlen(ppstr, 1)) {
|
||||||
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mbedtls_oid_get_extended_key_usage(&asn1_buf, &ppstr);
|
mbedtls_oid_get_extended_key_usage(&asn1_buf, &ppstr);
|
||||||
if (ppstr && strnlen(ppstr, 1)) {
|
if (ppstr && str_nlen(ppstr, 1)) {
|
||||||
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
PrintAndLogEx(NORMAL, " (%s)", ppstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "mifare/mad.h"
|
#include "mifare/mad.h"
|
||||||
#include "mifare/aiddesfire.h"
|
#include "mifare/aiddesfire.h"
|
||||||
|
|
||||||
|
|
||||||
const CLIParserOption DesfireAlgoOpts[] = {
|
const CLIParserOption DesfireAlgoOpts[] = {
|
||||||
{T_DES, "des"},
|
{T_DES, "des"},
|
||||||
{T_3DES, "2tdea"},
|
{T_3DES, "2tdea"},
|
||||||
|
@ -1749,7 +1750,7 @@ int DesfireFillAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS ap
|
||||||
memcpy(
|
memcpy(
|
||||||
appList[indx].appDFName,
|
appList[indx].appDFName,
|
||||||
&buf[i * 24 + 1 + 5],
|
&buf[i * 24 + 1 + 5],
|
||||||
// strnlen((char *)&buf[i * 24 + 1 + 5], 16)
|
// str_nlen((char *)&buf[i * 24 + 1 + 5], 16)
|
||||||
16
|
16
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2879,7 +2880,7 @@ int DesfireISOSelect(DesfireContext_t *dctx, DesfireISOSelectControl cntr, uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
int DesfireISOSelectDF(DesfireContext_t *dctx, char *dfname, uint8_t *resp, size_t *resplen) {
|
int DesfireISOSelectDF(DesfireContext_t *dctx, char *dfname, uint8_t *resp, size_t *resplen) {
|
||||||
return DesfireISOSelect(dctx, ISSDFName, (uint8_t *)dfname, strnlen(dfname, 16), resp, resplen);
|
return DesfireISOSelect(dctx, ISSDFName, (uint8_t *)dfname, str_nlen(dfname, 16), resp, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DesfireISOGetChallenge(DesfireContext_t *dctx, DesfireCryptoAlgorithm keytype, uint8_t *resp, size_t *resplen) {
|
int DesfireISOGetChallenge(DesfireContext_t *dctx, DesfireCryptoAlgorithm keytype, uint8_t *resp, size_t *resplen) {
|
||||||
|
|
|
@ -1198,6 +1198,16 @@ char *str_ndup(const char *src, size_t len) {
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t str_nlen(const char *src, size_t maxlen) {
|
||||||
|
size_t len = 0;
|
||||||
|
if(src {
|
||||||
|
for(char c = *src; (len < maxlen && c != '\0'); c = *++src) {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a hex string to component "hi2", "hi" and "lo" 32-bit integers
|
* Converts a hex string to component "hi2", "hi" and "lo" 32-bit integers
|
||||||
* one nibble at a time.
|
* one nibble at a time.
|
||||||
|
|
|
@ -147,6 +147,7 @@ void strcleanrn(char *buf, size_t len);
|
||||||
void strcreplace(char *buf, size_t len, char from, char to);
|
void strcreplace(char *buf, size_t len, char from, char to);
|
||||||
char *str_dup(const char *src);
|
char *str_dup(const char *src);
|
||||||
char *str_ndup(const char *src, size_t len);
|
char *str_ndup(const char *src, size_t len);
|
||||||
|
size_t str_nlen(const char *src, size_t maxlen);
|
||||||
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||||
int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||||
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const uint8_t *arr, int arrlen);
|
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const uint8_t *arr, int arrlen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue