summaryrefslogtreecommitdiff
path: root/src/tools/irm/irm_ipcp_enroll.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2022-02-25 00:15:31 +0100
committerSander Vrijders <[email protected]>2022-03-03 12:00:54 +0100
commit42dc4a5ed2037daa5631047af6613a45ad157d13 (patch)
tree70159d6a9ae3ba764b9061538777c07186fc0f71 /src/tools/irm/irm_ipcp_enroll.c
parentb3810b664aa3422d0c69c8fcf713c24d7bf16c26 (diff)
downloadouroboros-42dc4a5ed2037daa5631047af6613a45ad157d13.tar.gz
ouroboros-42dc4a5ed2037daa5631047af6613a45ad157d13.zip
tools: Fix signed/unsigned mismatch in irm_enroll
The irm_list_ipcps function can return negative values. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/tools/irm/irm_ipcp_enroll.c')
-rw-r--r--src/tools/irm/irm_ipcp_enroll.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c
index 2feffc54..5b9368f3 100644
--- a/src/tools/irm/irm_ipcp_enroll.c
+++ b/src/tools/irm/irm_ipcp_enroll.c
@@ -64,8 +64,8 @@ static int get_layer_name(const char * ipcp,
char * layer_name)
{
struct ipcp_info * ipcps;
- size_t len;
- size_t i;
+ ssize_t len;
+ ssize_t i;
len = irm_list_ipcps(&ipcps);
for (i = 0; i < len; i++)
@@ -146,40 +146,39 @@ int do_enroll_ipcp(int argc,
}
for (i = 0; i < len; i++) {
+ char enr_layer[LAYER_NAME_SIZE];
if (ipcps[i].type != type)
continue;
- if (wildcard_match(ipcps[i].name, ipcp) == 0) {
- char enr_layer[LAYER_NAME_SIZE];
+ if (wildcard_match(ipcps[i].name, ipcp) != 0)
+ continue;
- pid = ipcps[i].pid;
+ pid = ipcps[i].pid;
+
+ if (irm_enroll_ipcp(pid, dst)) {
+ printf("Failed to enroll IPCP.\n");
+ goto fail;
+ }
+
+ if (get_layer_name(ipcps[i].name, enr_layer)) {
+ printf("Could not get layer name.\n");
+ goto fail;
+ }
- if (irm_enroll_ipcp(pid, dst)) {
- printf("Failed to enroll IPCP.\n");
- goto fail;
- }
-
- if (get_layer_name(ipcps[i].name, enr_layer)) {
- printf("Could not get layer name.\n");
- goto fail;
- }
-
- if (layer != NULL && strcmp(enr_layer, layer)) {
- printf("Enrollment destination does not "
- "match requested layer.\n");
- goto fail;
- }
-
- if (autobind && irm_bind_process(pid, ipcp)) {
- printf("Failed to bind %d to %s.\n", pid, ipcp);
- goto fail;
- }
-
- if (autobind && irm_bind_process(pid, enr_layer)) {
- printf("Failed to bind %d to %s.\n",
- pid, enr_layer);
- goto fail;
- }
+ if (layer != NULL && strcmp(enr_layer, layer)) {
+ printf("Enrollment destination does not "
+ "match requested layer.\n");
+ goto fail;
+ }
+
+ if (autobind && irm_bind_process(pid, ipcp)) {
+ printf("Failed to bind %d to %s.\n", pid, ipcp);
+ goto fail;
+ }
+
+ if (autobind && irm_bind_process(pid, enr_layer)) {
+ printf("Failed to bind %d to %s.\n", pid, enr_layer);
+ goto fail;
}
}