Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_editable.c e_entry.c 


Log Message:
nuke memory that stored passwords in a few more cases
double click to select a word in an entry. triple click to select the whole 
thing

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_editable.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- e_editable.c        22 Apr 2007 03:50:44 -0000      1.18
+++ e_editable.c        22 Apr 2007 05:30:37 -0000      1.19
@@ -202,7 +202,9 @@
    
    if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
      return;
-   
+  
+   if (sd->password_mode) 
+     memset(sd->text, 0, sd->char_length);
    free(sd->text);
    sd->text = NULL;
    sd->char_length = 0;
@@ -639,6 +641,48 @@
 }
 
 /**
+ * Selects the word at the provided character index
+ */
+EAPI void
+e_editable_select_word(Evas_Object *editable, int index)
+{
+   E_Editable_Smart_Data *sd;
+   int spos, epos, i, pos;
+
+   if (!editable || (!(sd = evas_object_smart_data_get(editable))))
+     return;
+
+   if (index < 0 || index >= sd->unicode_length)
+     return;
+
+   i = 0;
+   spos = 0;
+   epos = -1;
+   pos = 0;
+   while (i < sd->char_length)
+     {
+       if (sd->text[i] == ' ')
+         {
+            if (pos < index)
+              spos = pos + 1;
+            else if (pos > index)
+              {
+                 epos = pos;
+                 break;
+              }
+         }
+
+       i = evas_string_char_next_get(sd->text, i, NULL);
+       pos++;
+     }
+   if (epos == -1)
+     epos = pos;
+
+   e_editable_selection_pos_set(editable, spos);
+   e_editable_cursor_pos_set(editable, epos);
+}
+
+/**
  * Shows the selection of the editable object
  *
  * @param editable an editable object
@@ -841,8 +885,20 @@
    
    if (sd->char_length > sd->allocated_length)
      {
-        sd->text = realloc(sd->text,
+       if (sd->password_mode)
+         {
+            /* security -- copy contents into new buffer, and overwrite old 
contents */
+            char *old = sd->text;
+            sd->text = malloc(E_EDITABLE_SIZE_TO_ALLOC(sd->char_length) + 1);
+            memcpy(sd->text, old, sd->char_length + 1);
+            memset(old, 0, sd->char_length);
+            free(old);
+         }
+       else
+         {
+            sd->text = realloc(sd->text,
                            E_EDITABLE_SIZE_TO_ALLOC(sd->char_length) + 1);
+         }
         sd->allocated_length = E_EDITABLE_SIZE_TO_ALLOC(sd->char_length);
      }
    
@@ -1181,7 +1237,7 @@
    evas_object_del(sd->selection_object);
    /* Security - clear out memory that contained a password */
    if (sd->password_mode) 
-     memset(sd->text, 0, strlen(sd->text));
+     memset(sd->text, 0, sd->char_length);
    free(sd->text);
    free(sd);
    
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_entry.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- e_entry.c   22 Apr 2007 04:40:40 -0000      1.38
+++ e_entry.c   22 Apr 2007 05:30:37 -0000      1.39
@@ -315,12 +315,18 @@
    pos = e_editable_pos_get_from_coords(sd->editable_object,
                                         event->canvas.x - ox,
                                         event->canvas.y - oy);
-   
+  
+   printf("MOUSE DOWN: %d\n", pos);
    if (event->button == 1)
      {
-        if (event->flags & EVAS_BUTTON_DOUBLE_CLICK)
+       if (event->flags & EVAS_BUTTON_TRIPLE_CLICK)
          {
             e_editable_select_all(sd->editable_object);
+            _e_entry_x_selection_update(obj);
+         }
+       else if (event->flags & EVAS_BUTTON_DOUBLE_CLICK)
+         {
+            e_editable_select_word(sd->editable_object, pos);
             _e_entry_x_selection_update(obj);
          }
         else



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to