fix issues in spilling ndef data to stdout and fix bug in mifare-desfire-write-ndef
This commit is contained in:
parent
23700b5cdd
commit
e096f1f421
4 changed files with 7 additions and 13 deletions
|
@ -151,11 +151,11 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
bool read_ndef = true;
|
bool read_ndef = true;
|
||||||
if (read_options.interactive) {
|
if (read_options.interactive) {
|
||||||
printf ("Read NDEF [yN] ");
|
fprintf (message_stream, "Read NDEF [yN] ");
|
||||||
fgets (buffer, BUFSIZ, stdin);
|
fgets (buffer, BUFSIZ, stdin);
|
||||||
read_ndef = ((buffer[0] == 'y') || (buffer[0] == 'Y'));
|
read_ndef = ((buffer[0] == 'y') || (buffer[0] == 'Y'));
|
||||||
} else {
|
} else {
|
||||||
printf ("\n");
|
fprintf (message_stream, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_ndef) {
|
if (read_ndef) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct {
|
||||||
void
|
void
|
||||||
usage(char *progname)
|
usage(char *progname)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "This application turns Mifare DESFire targets into NFC Forum Type 4 Tags.\n");
|
||||||
fprintf (stderr, "usage: %s [-y] [-K 11223344AABBCCDD]\n", progname);
|
fprintf (stderr, "usage: %s [-y] [-K 11223344AABBCCDD]\n", progname);
|
||||||
fprintf (stderr, "\nOptions:\n");
|
fprintf (stderr, "\nOptions:\n");
|
||||||
fprintf (stderr, " -y Do not ask for confirmation\n");
|
fprintf (stderr, " -y Do not ask for confirmation\n");
|
||||||
|
@ -91,8 +92,6 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
||||||
|
|
||||||
printf ("NOTE: This application turns Mifare DESFire targets into NFC Forum Type 4 Tags.\n");
|
|
||||||
|
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct {
|
||||||
void
|
void
|
||||||
usage(char *progname)
|
usage(char *progname)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "This application reads a NDEF payload from a Mifare DESFire formatted as NFC Forum Type 4 Tag.\n");
|
||||||
fprintf (stderr, "usage: %s [-y] -o FILE [-k 11223344AABBCCDD]\n", progname);
|
fprintf (stderr, "usage: %s [-y] -o FILE [-k 11223344AABBCCDD]\n", progname);
|
||||||
fprintf (stderr, "\nOptions:\n");
|
fprintf (stderr, "\nOptions:\n");
|
||||||
fprintf (stderr, " -y Do not ask for confirmation\n");
|
fprintf (stderr, " -y Do not ask for confirmation\n");
|
||||||
|
@ -100,8 +101,6 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
||||||
|
|
||||||
printf ("NOTE: This application reads a NDEF payload from a Mifare DESFire formatted as NFC Forum Type 4 Tag.\n");
|
|
||||||
|
|
||||||
if (ndef_output == NULL) {
|
if (ndef_output == NULL) {
|
||||||
usage (argv[0]);
|
usage (argv[0]);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
@ -156,11 +155,11 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
bool read_ndef = true;
|
bool read_ndef = true;
|
||||||
if (read_options.interactive) {
|
if (read_options.interactive) {
|
||||||
printf ("Read NDEF [yN] ");
|
fprintf (message_stream, "Read NDEF [yN] ");
|
||||||
fgets (buffer, BUFSIZ, stdin);
|
fgets (buffer, BUFSIZ, stdin);
|
||||||
read_ndef = ((buffer[0] == 'y') || (buffer[0] == 'Y'));
|
read_ndef = ((buffer[0] == 'y') || (buffer[0] == 'Y'));
|
||||||
} else {
|
} else {
|
||||||
printf ("\n");
|
fprintf (message_stream, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_ndef) {
|
if (read_ndef) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ struct {
|
||||||
void
|
void
|
||||||
usage(char *progname)
|
usage(char *progname)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "This application writes a NDEF payload into a Mifare DESFire formatted as NFC Forum Type 4 Tag.\n");
|
||||||
fprintf (stderr, "usage: %s [-y] -i FILE [-k 11223344AABBCCDD]\n", progname);
|
fprintf (stderr, "usage: %s [-y] -i FILE [-k 11223344AABBCCDD]\n", progname);
|
||||||
fprintf (stderr, "\nOptions:\n");
|
fprintf (stderr, "\nOptions:\n");
|
||||||
fprintf (stderr, " -y Do not ask for confirmation\n");
|
fprintf (stderr, " -y Do not ask for confirmation\n");
|
||||||
|
@ -108,10 +109,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
// Remaining args, if any, are in argv[optind .. (argc-1)]
|
||||||
|
|
||||||
printf ("NOTE: This application writes a NDEF payload into a Mifare DESFire formatted as NFC Forum Type 4 Tag.\n");
|
|
||||||
|
|
||||||
if (ndef_input == NULL) {
|
if (ndef_input == NULL) {
|
||||||
ndef_msg = (uint8_t*)ndef_default_msg;
|
|
||||||
ndef_msg_len = sizeof(ndef_default_msg) + 2;
|
ndef_msg_len = sizeof(ndef_default_msg) + 2;
|
||||||
if (!(ndef_msg = malloc (ndef_msg_len))) {
|
if (!(ndef_msg = malloc (ndef_msg_len))) {
|
||||||
err (EXIT_FAILURE, "malloc");
|
err (EXIT_FAILURE, "malloc");
|
||||||
|
@ -243,8 +241,6 @@ main(int argc, char *argv[])
|
||||||
uint8_t file_no = cc_data[off+3];
|
uint8_t file_no = cc_data[off+3];
|
||||||
uint16_t ndefmaxlen = (((uint16_t) cc_data[off+4]) << 8) + ((uint16_t) cc_data[off+5]);
|
uint16_t ndefmaxlen = (((uint16_t) cc_data[off+4]) << 8) + ((uint16_t) cc_data[off+5]);
|
||||||
fprintf (stdout, "Max NDEF size: %i bytes\n", ndefmaxlen);
|
fprintf (stdout, "Max NDEF size: %i bytes\n", ndefmaxlen);
|
||||||
if (!(ndef_msg = malloc(ndefmaxlen)))
|
|
||||||
errx (EXIT_FAILURE, "malloc");
|
|
||||||
if (ndef_msg_len > ndefmaxlen)
|
if (ndef_msg_len > ndefmaxlen)
|
||||||
errx (EXIT_FAILURE, "Supplied NDEF larger than max NDEF size");
|
errx (EXIT_FAILURE, "Supplied NDEF larger than max NDEF size");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue