mirror of
https://github.com/Kiritow/image-station.git
synced 2024-03-22 13:30:54 +08:00
fix SIGSEGV
This commit is contained in:
parent
831847c3c1
commit
93abfd63c8
16
frpc/main.c
16
frpc/main.c
|
@ -43,6 +43,11 @@ int main(int argc, char *argv[])
|
||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(optarg, "r");
|
FILE *fp = fopen(optarg, "r");
|
||||||
|
if(!fp)
|
||||||
|
{
|
||||||
|
perror("fopen");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
fscanf(fp, "%s", token);
|
fscanf(fp, "%s", token);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
enableToken = 1;
|
enableToken = 1;
|
||||||
|
@ -56,9 +61,9 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind + 5 > argc)
|
if (optind + 6 > argc)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "not enough arguments, 5 needed, got %d\n", argc - optind);
|
fprintf(stderr, "not enough arguments, 6 needed, got %d\n", argc - optind);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +87,11 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fp = fopen("/tmp/frpc.ini", "w");
|
FILE *fp = fopen("/tmp/frpc.ini", "w");
|
||||||
|
if(!fp)
|
||||||
|
{
|
||||||
|
perror("fopen");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
fprintf(fp, "[common]\nserver_addr = %s\nserver_port = %d\n", serverIP, serverPort);
|
fprintf(fp, "[common]\nserver_addr = %s\nserver_port = %d\n", serverIP, serverPort);
|
||||||
if (enableToken)
|
if (enableToken)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +123,7 @@ int main(int argc, char *argv[])
|
||||||
if (!noExec)
|
if (!noExec)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Loading frpc...\n");
|
fprintf(stderr, "Loading frpc...\n");
|
||||||
char *callArgs[] = {"The Frp Client", "-c", "/tmp/frpc.ini", NULL};
|
char* const callArgs[] = {"The Frp Client", "-c", "/tmp/frpc.ini", NULL};
|
||||||
if (execv("/opt/frp/frpc", callArgs) < 0)
|
if (execv("/opt/frp/frpc", callArgs) < 0)
|
||||||
{
|
{
|
||||||
perror("execv");
|
perror("execv");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user