[gnome-commander/gcmd-1-2-8: 9/9] Fixed problem #591206 (crash while sysconf() on FreeBSD)



commit 390867cc09f2b0c2ababe268abf8ca6f6f658beb
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Mon Aug 10 19:06:39 2009 +0200

    Fixed problem #591206 (crash while sysconf() on FreeBSD)

 NEWS                      |    1 +
 doc/C/gnome-commander.xml |    3 +++
 src/owner.cc              |    8 +++++++-
 3 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index db8cf88..820f218 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ gnome-commander 1.2.8.1
 Bug fixes:
  * Fixed problem #587325 (crash in a clean chroot environment)
  * Fixed problem #589108 (build error on openSUSE)
+ * Fixed problem #591206 (crash while sysconf() on FreeBSD)
  * Fixed problem with $c(16) counter formatting in advanced file rename templates
 
 
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index e8161bb..2f0bac3 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -5988,6 +5988,9 @@
                             <para>Fixed problem #589108 (build error on openSUSE)</para>
                         </listitem>
                         <listitem>
+                            <para>Fixed problem #591206 (crash while sysconf() on FreeBSD)</para>
+                        </listitem>
+                        <listitem>
                             <para>Fixed problem with $c(16) counter formatting in advanced file rename templates</para>
                         </listitem>
                     </itemizedlist>
diff --git a/src/owner.cc b/src/owner.cc
index 552cc67..4c5803d 100644
--- a/src/owner.cc
+++ b/src/owner.cc
@@ -62,7 +62,13 @@ GnomeCmdOwner::GnomeCmdOwner()
 
     if (!buff)
     {
-        buffsize = max(sysconf(_SC_GETPW_R_SIZE_MAX), sysconf(_SC_GETGR_R_SIZE_MAX));
+        long int pw_size = sysconf(_SC_GETPW_R_SIZE_MAX);
+        long int gr_size = sysconf(_SC_GETGR_R_SIZE_MAX);
+
+        if (pw_size==-1)    pw_size = 4096;     // `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value.
+        if (gr_size==-1)    gr_size = 4096;     // `sysconf' does not support _SC_GETGR_R_SIZE_MAX. Try a moderate value.
+
+        buffsize = max(pw_size, gr_size);
         buff = g_new0 (char, buffsize);
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]