summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2016-07-18 23:10:33 +0200
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-03-24 17:51:28 -0700
commitb086401357cfdf02cbd52d29dcd604f6cabaa1d8 (patch)
treea0f5a346f95678048b2b4f91a4862c317f22f2d0
parentb792adfce0127237739b906ddb28a246d23c81ae (diff)
Properly handle failures of Xv query functions.
If one of the query functions fail, xvinfo does not properly handle these cases and will most likely run into a segmentation fault due to accessing uninitialized variables (which includes pointers). Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xvinfo.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/xvinfo.c b/xvinfo.c
index 891c8c2..db1a008 100644
--- a/xvinfo.c
+++ b/xvinfo.c
@@ -71,7 +71,7 @@ main(int argc, char *argv[])
exit(-1);
}
- if ((Success != XvQueryExtension(dpy, &ver, &rev, &reqB, &eventB, &errorB))) {
+ if (Success != XvQueryExtension(dpy, &ver, &rev, &reqB, &eventB, &errorB)) {
fprintf(stderr, "%s: No X-Video Extension on %s\n", progname,
(disname != NULL) ? disname : XDisplayName(NULL));
exit(0);
@@ -84,7 +84,12 @@ main(int argc, char *argv[])
for (i = 0; i < nscreens; i++) {
fprintf(stdout, "screen #%i\n", i);
- XvQueryAdaptors(dpy, RootWindow(dpy, i), &nadaptors, &ainfo);
+ if (Success != XvQueryAdaptors(dpy, RootWindow(dpy, i), &nadaptors,
+ &ainfo)) {
+ fprintf(stderr, "%s: Failed to query adaptors on display %s\n",
+ progname, (disname != NULL) ? disname : XDisplayName(NULL));
+ exit(-1);
+ }
if (!nadaptors) {
fprintf(stdout, " no adaptors present\n");
@@ -178,7 +183,14 @@ main(int argc, char *argv[])
fprintf(stdout, " no port attributes defined\n");
}
- XvQueryEncodings(dpy, ainfo[j].base_id, &nencode, &encodings);
+ if (Success != XvQueryEncodings(dpy, ainfo[j].base_id, &nencode,
+ &encodings)) {
+ fprintf(stderr,
+ "%s: Failed to query encodings on display %s\n",
+ progname,
+ (disname != NULL) ? disname : XDisplayName(NULL));
+ exit(-1);
+ }
if (encodings && nencode) {
unsigned int ImageEncodings = 0;