mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-30 05:50:53 +03:00
test for -1 (EOF) sscanf result
This commit is contained in:
parent
606063dd48
commit
2a3b9cf982
@ -184,7 +184,7 @@ static void parse_params(int argc, char *argv[])
|
|||||||
case 4:
|
case 4:
|
||||||
i = sscanf(optarg,"%u-%u",&plen1,&plen2);
|
i = sscanf(optarg,"%u-%u",&plen1,&plen2);
|
||||||
if (i == 1) plen2 = plen1;
|
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);
|
fprintf(stderr, "invalid parameter for prefix-length : %s\n", optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -245,17 +245,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
// we have subnet ip6/y
|
// we have subnet ip6/y
|
||||||
// output it as is
|
// output it as is
|
||||||
*s = d;
|
if (sscanf(s + 1, "%u", &zct)==1 && zct!=128)
|
||||||
if (sscanf(s + 1, "%u", &zct) && zct!=128)
|
|
||||||
{
|
{
|
||||||
if (zct<128) printf("%s\n", str);
|
if (zct<128) printf("%s/%u\n", str, zct);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (d=='-')
|
else if (d=='-')
|
||||||
{
|
{
|
||||||
*s = d;
|
if (inet_pton(AF_INET6, s+1, &a)) printf("%s-%s\n", str, s+1);
|
||||||
if (inet_pton(AF_INET6, s+1, &a)) printf("%s\n", str);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ipct >= iplist_size)
|
if (ipct >= iplist_size)
|
||||||
|
@ -204,7 +204,7 @@ static void *t_resolver(void *arg)
|
|||||||
bool mask_needed = false;
|
bool mask_needed = false;
|
||||||
if (s_mask)
|
if (s_mask)
|
||||||
{
|
{
|
||||||
if (sscanf(s_mask, "%u", &mask))
|
if (sscanf(s_mask, "%u", &mask)==1)
|
||||||
{
|
{
|
||||||
switch (family)
|
switch (family)
|
||||||
{
|
{
|
||||||
|
@ -348,7 +348,7 @@ void parse_params(int argc, char *argv[])
|
|||||||
case 13: /* uid */
|
case 13: /* uid */
|
||||||
params.gid=0x7FFFFFFF; // default git. drop gid=0
|
params.gid=0x7FFFFFFF; // default git. drop gid=0
|
||||||
params.droproot = true;
|
params.droproot = true;
|
||||||
if (!sscanf(optarg,"%u:%u",¶ms.uid,¶ms.gid))
|
if (sscanf(optarg,"%u:%u",¶ms.uid,¶ms.gid)<1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "--uid should be : uid[:gid]\n");
|
fprintf(stderr, "--uid should be : uid[:gid]\n");
|
||||||
exit_clean(1);
|
exit_clean(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user