Freebyte

vuln code

Feb 15th, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. static void get_new_session_id(Sessionhandler *self, char *session_id)
  2. {
  3.     time_t  now;
  4.     int     cnt = 0;
  5.     char    now_buf[20];     <-Vulnerability Code
  6.    
  7.     assert(self);
  8.     assert(session_id);
  9.     /* Start the try loop of generating unique id*/
  10.     do
  11.     {
  12.         /* Count the tries*/
  13.         cnt++;
  14.         /* Get the current time of the generation*/
  15.         time(&now);
  16.         /* Create a timeout limit for the new id by adding the timeout constant*/
  17.         now += self->_timeout;
  18.         self->_differ++;
  19.         /* Generate a id*/
  20.         generate_id(session_id, self->_differ);
  21.         /* Look in the session Map to se if the id is unique*/
  22.     }while(map_find(self->_sessions, session_id) != NULL && cnt < SESSION_MAX_TRY);
  23.     /* When we get here we probably have a unique id or
  24.      * else we accept the id anyway.
  25.      */
  26.     /* Put the id in the session Map*/
  27.     _ltoa((long)now, now_buf, 10);
  28.     map_add(self->_sessions, session_id, now_buf);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment