Thread: deploying glib function

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    deploying glib function

    I'm trying to track down a small overwrite. One of the potential culprits is of the glib "Miscellaneous Utility Functions", g_get_home_dir. According to the API, it returns a const gchar*. This means the pointer can be neither pre-allocated nor freed.

    Code:
    const gchar *homedir=g_get_home_dir();
    So I had been presuming that this is just a pointer to some data maintained by glib, but I have been running out of possible sources for my problem, and I thought I'd run this by cboard.

    Am I barking up the wrong tree?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Banned
    Join Date
    Dec 2008
    Location
    Maputo, Mozambique
    Posts
    82
    Code:
    struct c
    {
      void *x;
      struct c *t, *s;
    };
    
    struct c *waste(int iterations, struct c *o)
    {
      struct c *p = 0;
    
      if(iterations)
      {
        p = malloc(*p);
    
        if(p)
        {
          p->t = o;
          p->s = waste(iterations - 1, p);
          p->x = malloc(1);
        }
      }
    
      return p;
    }
    
    struct d
    {
      struct c *w;
      struct d *l, *r, *p;
    };
    
    struct d *disaster(void)
    {
      int r = ~rand();
      int iterations;
      struct d *q = malloc(sizeof *q);
    
      if(!q)
        return 0;
    
      if(r & 0x1000)
        iterations = (r%63) * r;
    
      if(r & 0x100)
        iterations = (r*r*r) / -r;
    
      p->c = waste(iterations, 0);
    
      if(r & 0x100100)
      {
         p->l = p-> r = NULL;
      } else if(r & 1)
      {
        p->l = NULL;
        p->r = waste(iterations/2, 0);
      } else
      {
        p->l = waste(iterations/3, 0);
        p->r = NULL;
      }
    
      return p;
    }
    
    int main(void)
    {
      disaster();
      return 0;
    }
    Ok there is sum code to help mess up ur computr. Iz that 4 help?

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I'm sensing:

    Code:
    c++0x->days=numbered;
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

Tags for this Thread