Check os_snprintf() result more consistently - automatic 1
This converts os_snprintf() result validation cases to use os_snprintf_error() where the exact rule used in os_snprintf_error() was used. These changes were done automatically with spatch using the following semantic patch: @@ identifier E1; expression E2,E3,E4,E5,E6; statement S1; @@ ( E1 = os_snprintf(E2, E3, ...); | int E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else if (E6) E1 = os_snprintf(E2, E3, ...); else E1 = 0; | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else if (E6) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... E1 = os_snprintf(E2, E3, ...); } ) ? os_free(E4); - if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \)) + if (os_snprintf_error(E3, E1)) ( S1 | { ... } ) Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a80ba67a26
commit
d85e1fc8a5
49 changed files with 343 additions and 343 deletions
|
@ -2359,7 +2359,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
sta->aid,
|
||||
EAPOL_VERSION,
|
||||
sm->initialize);
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
@ -2387,7 +2387,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
sm->reAuthPeriod,
|
||||
bool_txt(sm->reAuthEnabled),
|
||||
bool_txt(sm->keyTxEnabled));
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
@ -2417,7 +2417,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
sm->dot1xAuthEapLengthErrorFramesRx,
|
||||
sm->dot1xAuthLastEapolFrameVersion,
|
||||
MAC2STR(sm->addr));
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
@ -2455,7 +2455,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
sm->backendOtherRequestsToSupplicant,
|
||||
sm->backendAuthSuccesses,
|
||||
sm->backendAuthFails);
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
@ -2477,7 +2477,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
1 : 2,
|
||||
(unsigned int) diff.sec,
|
||||
sm->identity);
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
@ -2490,7 +2490,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
name1 ? name1 : "",
|
||||
sm->eap_type_supp,
|
||||
name2 ? name2 : "");
|
||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue