keygen: fixed bug where serial and mac would be truncated

This commit is contained in:
Giulio 2020-09-20 19:36:06 +02:00
parent ae9d150ffa
commit 176cdb2d42

View File

@ -175,7 +175,7 @@ char *get_mac()
FILE * fp; FILE * fp;
char *mac = malloc(18* sizeof(char)); char *mac = malloc(18* sizeof(char));
fp = fopen("/sys/class/net/ap0/address", "r"); fp = fopen("/sys/class/net/ap0/address", "r");
fgets(mac, 17, fp); fgets(mac, 18, fp);
fclose(fp); fclose(fp);
return mac; return mac;
} }
@ -183,9 +183,9 @@ char *get_mac()
char *get_serial() char *get_serial()
{ {
FILE * fp; FILE * fp;
char *serial = malloc(21* sizeof(char)); char *serial = malloc(33* sizeof(char));
fp = fopen("/etc/serial", "r"); fp = fopen("/etc/serial", "r");
fgets(serial, 20, fp); fgets(serial, 33, fp);
return serial; return serial;
} }