Browse Source

test for -1 (EOF) sscanf result

pull/84/head
bol-van 3 years ago
parent
commit
2a3b9cf982
  1. 10
      ip2net/ip2net.c
  2. 2
      mdig/mdig.c
  3. 2
      tpws/tpws.c

10
ip2net/ip2net.c

@ -184,7 +184,7 @@ static void parse_params(int argc, char *argv[])
case 4:
i = sscanf(optarg,"%u-%u",&plen1,&plen2);
if (i == 1) plen2 = plen1;
if (!i || plen2<plen1 || !plen1 || !plen2)
if (i<=0 || plen2<plen1 || !plen1 || !plen2)
{
fprintf(stderr, "invalid parameter for prefix-length : %s\n", optarg);
exit(1);
@ -245,17 +245,15 @@ int main(int argc, char **argv)
{
// we have subnet ip6/y
// output it as is
*s = d;
if (sscanf(s + 1, "%u", &zct) && zct!=128)
if (sscanf(s + 1, "%u", &zct)==1 && zct!=128)
{
if (zct<128) printf("%s\n", str);
if (zct<128) printf("%s/%u\n", str, zct);
continue;
}
}
else if (d=='-')
{
*s = d;
if (inet_pton(AF_INET6, s+1, &a)) printf("%s\n", str);
if (inet_pton(AF_INET6, s+1, &a)) printf("%s-%s\n", str, s+1);
continue;
}
if (ipct >= iplist_size)

2
mdig/mdig.c

@ -204,7 +204,7 @@ static void *t_resolver(void *arg)
bool mask_needed = false;
if (s_mask)
{
if (sscanf(s_mask, "%u", &mask))
if (sscanf(s_mask, "%u", &mask)==1)
{
switch (family)
{

2
tpws/tpws.c

@ -348,7 +348,7 @@ void parse_params(int argc, char *argv[])
case 13: /* uid */
params.gid=0x7FFFFFFF; // default git. drop gid=0
params.droproot = true;
if (!sscanf(optarg,"%u:%u",&params.uid,&params.gid))
if (sscanf(optarg,"%u:%u",&params.uid,&params.gid)<1)
{
fprintf(stderr, "--uid should be : uid[:gid]\n");
exit_clean(1);

Loading…
Cancel
Save