key参数长度导致bug修复
This commit is contained in:
parent
2a3d35e328
commit
15aba655f0
13
sha.c
13
sha.c
@ -753,7 +753,10 @@ void usage(void)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static uint8_t key[16] = "aixiao.me";
|
static uint8_t key[16] = "aixiao.me";
|
||||||
|
int key_l = 0;
|
||||||
char sh_file[1024];
|
char sh_file[1024];
|
||||||
|
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
char optstrs[] = ":k:f:h?";
|
char optstrs[] = ":k:f:h?";
|
||||||
while (-1 != (opt = getopt(argc, argv, optstrs))) {
|
while (-1 != (opt = getopt(argc, argv, optstrs))) {
|
||||||
@ -764,7 +767,6 @@ int main(int argc, char *argv[])
|
|||||||
case 'f':
|
case 'f':
|
||||||
strcpy((char *)sh_file, optarg);
|
strcpy((char *)sh_file, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
//printf("\nMissing argument after: -%c\n", optopt);
|
//printf("\nMissing argument after: -%c\n", optopt);
|
||||||
usage();
|
usage();
|
||||||
@ -777,11 +779,16 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen((char *)key) < 8) {
|
key_l = strlen((char *)key);
|
||||||
printf("Key must be at least 8 digits!\n");
|
//printf("%d\n", key_l);
|
||||||
|
|
||||||
|
|
||||||
|
if (key_l < 8 || key_l > 15) {
|
||||||
|
printf("The key must be 8-15 digits!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open_file(sh_file);
|
open_file(sh_file);
|
||||||
|
|
||||||
struct AES_ctx ctx;
|
struct AES_ctx ctx;
|
||||||
|
Loading…
Reference in New Issue
Block a user