[haiku-commits] r41090 - haiku/trunk/src/kits/tracker

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Mar 2011 01:47:22 +0100 (CET)

Author: kirilla
Date: 2011-03-23 01:47:21 +0100 (Wed, 23 Mar 2011)
New Revision: 41090
Changeset: https://dev.haiku-os.org/changeset/41090

Modified:
   haiku/trunk/src/kits/tracker/ContainerWindow.cpp
Log:
Use short-circuit evaluation to avoid out-of-bounds string access. Thanks 
J?\195?\131?\194?\169r?\195?\131?\194?\180me!

Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2011-03-22 23:00:27 UTC 
(rev 41089)
+++ haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2011-03-23 00:47:21 UTC 
(rev 41090)
@@ -171,7 +171,7 @@
 
        // check if there is a shortcut in the model name
        uint32 length = strlen(result);
-       if (result[length - 2] == '-' && length > 2) {
+       if (length > 2 && result[length - 2] == '-') {
                shortcut = result[length - 1];
                result[length - 2] = '\0';
                return;
@@ -180,7 +180,7 @@
        // check if there is a shortcut in the filename
        char* refName = model->EntryRef()->name;
        length = strlen(refName);
-       if (refName[length - 2] == '-' && length > 2) {
+       if (length > 2 && refName[length - 2] == '-') {
                shortcut = refName[length - 1];
                return;
        }


Other related posts:

  • » [haiku-commits] r41090 - haiku/trunk/src/kits/tracker - jonas