In src/client/client_cli.c lines 94 and 163, atoi() is used to parse port numbers:
config->ssh_port=atoi(argv[++i]);// line 94
server_port=atoi(argv[++i]);// line 163
atoi() has no error detection — it returns 0 for invalid input (e.g., --ssh-port abc would silently set port to 0), and cannot distinguish between a valid "0" and an error. The server also doesn't validate that the port is within the valid range (1-65535).
Location
src/client/client_cli.c:94, 163
Suggested Fix
Use strtol() with proper error checking, consistent with how the server parses port numbers in src/server/server.c:167-173:
char*end;longp=strtol(argv[i+1],&end,10);if(*end||p<=0||p>65535){fprintf(stderr,"Error: invalid port '%s' (must be 1-65535)\n",argv[i+1]);exit_code=1;gotocleanup;}config->ssh_port=(int)p;i++;
Severity
Medium
Category
Bug
## Description
In `src/client/client_cli.c` lines 94 and 163, `atoi()` is used to parse port numbers:
```c
config->ssh_port = atoi(argv[++i]); // line 94
server_port = atoi(argv[++i]); // line 163
```
`atoi()` has no error detection — it returns 0 for invalid input (e.g., `--ssh-port abc` would silently set port to 0), and cannot distinguish between a valid "0" and an error. The server also doesn't validate that the port is within the valid range (1-65535).
## Location
`src/client/client_cli.c:94, 163`
## Suggested Fix
Use `strtol()` with proper error checking, consistent with how the server parses port numbers in `src/server/server.c:167-173`:
```c
char* end;
long p = strtol(argv[i+1], &end, 10);
if (*end || p <= 0 || p > 65535) {
fprintf(stderr, "Error: invalid port '%s' (must be 1-65535)\n", argv[i+1]);
exit_code = 1;
goto cleanup;
}
config->ssh_port = (int)p;
i++;
```
## Severity
Medium
## Category
Bug
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
In
src/client/client_cli.clines 94 and 163,atoi()is used to parse port numbers:atoi()has no error detection — it returns 0 for invalid input (e.g.,--ssh-port abcwould silently set port to 0), and cannot distinguish between a valid "0" and an error. The server also doesn't validate that the port is within the valid range (1-65535).Location
src/client/client_cli.c:94, 163Suggested Fix
Use
strtol()with proper error checking, consistent with how the server parses port numbers insrc/server/server.c:167-173:Severity
Medium
Category
Bug