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:
Jouni Malinen 2014-12-08 11:15:51 +02:00
parent a80ba67a26
commit d85e1fc8a5
49 changed files with 343 additions and 343 deletions

View file

@ -3750,7 +3750,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
"[PD_FOR_JOIN]" : "",
dev->status,
dev->invitation_reqs);
if (res < 0 || res >= end - pos)
if (os_snprintf_error(end - pos, res))
return pos - buf;
pos += res;
@ -3760,7 +3760,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
"ext_listen_interval=%u\n",
dev->ext_listen_period,
dev->ext_listen_interval);
if (res < 0 || res >= end - pos)
if (os_snprintf_error(end - pos, res))
return pos - buf;
pos += res;
}
@ -3770,7 +3770,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
"oper_ssid=%s\n",
wpa_ssid_txt(dev->oper_ssid,
dev->oper_ssid_len));
if (res < 0 || res >= end - pos)
if (os_snprintf_error(end - pos, res))
return pos - buf;
pos += res;
}
@ -3778,7 +3778,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
#ifdef CONFIG_WIFI_DISPLAY
if (dev->info.wfd_subelems) {
res = os_snprintf(pos, end - pos, "wfd_subelems=");
if (res < 0 || res >= end - pos)
if (os_snprintf_error(end - pos, res))
return pos - buf;
pos += res;
@ -3787,7 +3787,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
wpabuf_len(dev->info.wfd_subelems));
res = os_snprintf(pos, end - pos, "\n");
if (res < 0 || res >= end - pos)
if (os_snprintf_error(end - pos, res))
return pos - buf;
pos += res;
}