Skip to content

Commit

Permalink
add check whether popen success or not
Browse files Browse the repository at this point in the history
Signed-off-by: staylightblow8 <[email protected]>
  • Loading branch information
liudf0716 committed Jan 3, 2024
1 parent 6265f6e commit 3631256
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/fw4_nft.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ nft_statistical_outgoing(char *outgoing, uint32_t outgoing_len)
char *cmd = "nft -j list chain inet fw4 mangle_prerouting_wifidogx_outgoing";
debug(LOG_DEBUG, "nft -j list chain inet fw4 mangle_prerouting_wifidogx_outgoing");
r_fp = popen(cmd, "r");
if (r_fp == NULL) {
debug(LOG_ERR, "popen failed");
return;
}
fgets(outgoing, outgoing_len, r_fp);
pclose(r_fp);
}
Expand All @@ -296,6 +300,10 @@ nft_statistical_incoming(char *incoming, uint32_t incoming_len)
char *cmd = "nft -j list chain inet fw4 mangle_postrouting_wifidogx_incoming";
debug(LOG_DEBUG, "nft -j list chain inet fw4 mangle_postrouting_wifidogx_incoming");
r_fp = popen(cmd, "r");
if (r_fp == NULL) {
debug(LOG_ERR, "popen failed");
return;
}
fgets(incoming, incoming_len, r_fp);
pclose(r_fp);
}
Expand Down

0 comments on commit 3631256

Please sign in to comment.