summaryrefslogtreecommitdiff
blob: 3bd142e1d732fd39e9e133169a379d4208b81a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--- xosview-1.8.2.orig/Xrm.cc
+++ xosview-1.8.2/Xrm.cc
@@ -148,20 +148,26 @@
 
   //  Merge in the system resource database.
   char rfilename[2048];
+  int result;
 
   // Get the app-defaults
+  //  Check /usr/lib/X11 for when /usr/X11R6 compatibility symlink is removed
+  result = snprintf(rfilename, sizeof rfilename, "/usr/lib/X11/app-defaults/%s",
+      XrmQuarkToString(_class));
+  if (result >= 0 && result < sizeof rfilename)
+    XrmCombineFileDatabase (rfilename, &_db, 1);
-  snprintf(rfilename, 2048, "/usr/X11R6/lib/X11/app-defaults/%s",
+  result = snprintf(rfilename, sizeof rfilename, "/usr/X11R6/lib/X11/app-defaults/%s",
       XrmQuarkToString(_class));
-  if (rfilename != NULL)
+  if (result >= 0 && result < sizeof rfilename)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   //  Try a few more, for SunOS/Solaris folks.
-  snprintf(rfilename, 2048, "/usr/openwin/lib/X11/app-defaults/%s",
+  result = snprintf(rfilename, sizeof rfilename, "/usr/openwin/lib/X11/app-defaults/%s",
       XrmQuarkToString(_class));
-  if (rfilename != NULL)
+  if (result >= 0 && result < sizeof rfilename)
     XrmCombineFileDatabase (rfilename, &_db, 1);
-  snprintf(rfilename, 2048, "/usr/local/X11R6/lib/X11/app-defaults/%s",
+  result = snprintf(rfilename, sizeof rfilename, "/usr/local/X11R6/lib/X11/app-defaults/%s",
       XrmQuarkToString(_class));
-  if (rfilename != NULL)
+  if (result >= 0 && result < sizeof rfilename)
     XrmCombineFileDatabase (rfilename, &_db, 1);
 
   //  Now, check for an XOSView file in the XAPPLRESDIR directory...