[libdvbpsi-devel] dvbinfo: Dereference after NULL check (CID 17248)
Jean-Paul Saman
git at videolan.org
Wed Apr 16 15:53:38 CEST 2014
libdvbpsi | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Wed Apr 16 11:45:13 2014 +0200| [1722b1da26164437376f19fc26d089614b19fb52] | committer: Jean-Paul Saman
dvbinfo: Dereference after NULL check (CID 17248)
> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=1722b1da26164437376f19fc26d089614b19fb52
---
examples/dvbinfo/dvbinfo.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/examples/dvbinfo/dvbinfo.c b/examples/dvbinfo/dvbinfo.c
index 8a7417d..0db5b4a 100644
--- a/examples/dvbinfo/dvbinfo.c
+++ b/examples/dvbinfo/dvbinfo.c
@@ -507,7 +507,7 @@ int main(int argc, char **pp_argv)
{ NULL, 0, NULL, 0 }
};
#ifdef HAVE_SYS_SOCKET_H
- while ((c = getopt_long(argc, pp_argv, "a:d:f:i:ho:ms:tu", long_options, NULL)) != -1)
+ while ((c = getopt_long(argc, pp_argv, "a:d:f:i:j:ho:p:ms:tu", long_options, NULL)) != -1)
#else
while ((c = getopt_long(argc, pp_argv, "d:f:h", long_options, NULL)) != -1)
#endif
@@ -603,17 +603,26 @@ int main(int argc, char **pp_argv)
/* - Statistics */
case 's':
{
- param->b_summary = true;
- ssize_t size = ARRAY_SIZE(psz_summary_mode);
- for (ssize_t i = 0; i < size; i++)
+ if (optarg)
{
- printf("summary mode %s\n", psz_summary_mode[i]);
- if (strncmp(optarg, psz_summary_mode[i], strlen(psz_summary_mode[i])) == 0)
+ ssize_t size = ARRAY_SIZE(psz_summary_mode);
+ for (ssize_t i = 0; i < size; i++)
{
- param->summary.mode = i_summary_mode[i];
- break;
+ printf("summary mode %s\n", psz_summary_mode[i]);
+ if (strncmp(optarg, psz_summary_mode[i], strlen(psz_summary_mode[i])) == 0)
+ {
+ param->summary.mode = i_summary_mode[i];
+ param->b_summary = true;
+ break;
+ }
}
}
+ if (!param->b_summary)
+ {
+ fprintf(stderr, "Option --summary has invalid content %s\n", optarg);
+ params_free(param);
+ usage();
+ }
break;
}
case 'j':
@@ -628,6 +637,7 @@ int main(int argc, char **pp_argv)
break;
case 'p':
+ if (optarg)
{
param->summary.period = strtoll(optarg, NULL, 10);
if (((errno == ERANGE) &&
More information about the libdvbpsi-devel
mailing list