mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-24 08:05:13 +08:00
fix coverity CID 322671, 322668, and time now is zero padded
This commit is contained in:
parent
3d8b165033
commit
16c43bea2d
1 changed files with 21 additions and 8 deletions
|
@ -97,7 +97,10 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
|
||||||
|
|
||||||
memcpy(ring_buffer, fpga_config + current_in, bytes_to_copy);
|
memcpy(ring_buffer, fpga_config + current_in, bytes_to_copy);
|
||||||
int cmp_bytes = LZ4_compress_HC_continue(lz4_streamhc, ring_buffer, outbuf, bytes_to_copy, outsize_max);
|
int cmp_bytes = LZ4_compress_HC_continue(lz4_streamhc, ring_buffer, outbuf, bytes_to_copy, outsize_max);
|
||||||
|
if (cmp_bytes < 0 ){
|
||||||
|
fprintf(stderr, "(lz4 - zlib_compress) error, got negative number of bytes from LZ4_compress_HC_continue call. got %d ", cmp_bytes);
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
fwrite(&cmp_bytes, sizeof(int), 1, outfile);
|
fwrite(&cmp_bytes, sizeof(int), 1, outfile);
|
||||||
fwrite(outbuf, sizeof(char), cmp_bytes, outfile);
|
fwrite(outbuf, sizeof(char), cmp_bytes, outfile);
|
||||||
|
|
||||||
|
@ -118,7 +121,7 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
|
||||||
fprintf(stdout, "compressed %u input bytes to %d output bytes\n", total_size, current_out);
|
fprintf(stdout, "compressed %u input bytes to %d output bytes\n", total_size, current_out);
|
||||||
|
|
||||||
if (current_out == 0) {
|
if (current_out == 0) {
|
||||||
fprintf(stderr, "Error in lz4");
|
fprintf(stderr, "error in lz4");
|
||||||
return (EXIT_FAILURE);
|
return (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
|
@ -204,18 +207,27 @@ static int bitparse_find_section(FILE *infile, char section_name, unsigned int *
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unsigned int current_length = 0;
|
unsigned int current_length = 0;
|
||||||
|
int tmp;
|
||||||
switch (current_name) {
|
switch (current_name) {
|
||||||
case 'e':
|
case 'e':
|
||||||
/* Four byte length field */
|
/* Four byte length field */
|
||||||
current_length += fgetc(infile) << 24;
|
for (int i = 0; i < 4; i++) {
|
||||||
current_length += fgetc(infile) << 16;
|
tmp = fgetc(infile);
|
||||||
current_length += fgetc(infile) << 8;
|
if (tmp < 0 ) {
|
||||||
current_length += fgetc(infile) << 0;
|
break;
|
||||||
|
}
|
||||||
|
current_length += tmp << (24 - (i * 8));
|
||||||
|
}
|
||||||
numbytes += 4;
|
numbytes += 4;
|
||||||
break;
|
break;
|
||||||
default: /* Fall through, two byte length field */
|
default: /* Fall through, two byte length field */
|
||||||
current_length += fgetc(infile) << 8;
|
for (int i = 0; i < 2; i++) {
|
||||||
current_length += fgetc(infile) << 0;
|
tmp = fgetc(infile);
|
||||||
|
if (tmp < 0 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
current_length += tmp << (8 - (i * 8));
|
||||||
|
}
|
||||||
numbytes += 2;
|
numbytes += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -290,6 +302,7 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len
|
||||||
for (uint16_t i = 0; i < fpga_info_len; i++) {
|
for (uint16_t i = 0; i < fpga_info_len; i++) {
|
||||||
char c = (char)fgetc(infile);
|
char c = (char)fgetc(infile);
|
||||||
if (i < sizeof(tempstr)) {
|
if (i < sizeof(tempstr)) {
|
||||||
|
if (c == ' ') c = '0';
|
||||||
tempstr[i] = c;
|
tempstr[i] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue