Check os_snprintf() result more consistently - automatic 3
authorJouni Malinen <j@w1.fi>
Mon, 8 Dec 2014 09:22:52 +0000 (11:22 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 8 Dec 2014 09:42:07 +0000 (11:42 +0200)
commiteeab4f2fdaf20b23f1c27c5ce7f655442e2f7902
tree45b51c109852c120ee503ffb168a7af5591b88d6
parent7bdd8981f7a62e4a5196254b9542b773e37d97cc
Check os_snprintf() result more consistently - automatic 3

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the comparison was 'res > size' instead of
'res >= size - 1'. 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 || (size_t) E1 >= E3 - 1)
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
hostapd/hostapd_cli.c
wpa_supplicant/wpa_cli.c