Thread: Customised Beanstalk Memory Crash

  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    4

    Customised Beanstalk Memory Crash

    My changes are working as designed, however, it crashes out if you enter a tube name above 12 characters.

    If this is a new tube then create a new Announce tube using -A NAME … * BiGMiCR0/beanstalkd@df6f115 * GitHub

    Have been trying to write unit tests for this with no success as well as fix the problem?

    Big thanks in advance if anyone has any ideas.

    Code:
    
    
    Code:
    ==15169== Command: ./beanstalkd -A testtubename
    ==15169== 
    ==15169== Invalid write of size 1
    ==15169==    at 0x4C3275B: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==15169==    by 0x40962E: dispatch_cmd (prot.c:1550)
    ==15169==    by 0x409D65: do_cmd (prot.c:1678)
    ==15169==    by 0x409EFF: conn_data (prot.c:1718)
    ==15169==    by 0x40A46E: h_conn (prot.c:1860)
    ==15169==    by 0x40A520: prothandle (prot.c:1872)
    ==15169==    by 0x40BC98: srvserve (serv.c:56)
    ==15169==    by 0x40DCE1: main (main.c:91)
    ==15169==  Address 0x52090aa is 0 bytes after a block of size 186 alloc'd
    ==15169==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==15169==    by 0x4043A1: allocate_job (job.c:97)
    ==15169==    by 0x40444B: make_job_with_id (job.c:113)
    ==15169==    by 0x409591: dispatch_cmd (prot.c:1549)
    ==15169==    by 0x409D65: do_cmd (prot.c:1678)
    ==15169==    by 0x409EFF: conn_data (prot.c:1718)
    ==15169==    by 0x40A46E: h_conn (prot.c:1860)
    ==15169==    by 0x40A520: prothandle (prot.c:1872)
    ==15169==    by 0x40BC98: srvserve (serv.c:56)
    ==15169==    by 0x40DCE1: main (main.c:91)

    Last edited by MiCR0; 07-17-2017 at 10:19 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > + c->in_job = make_job(5, 0, 1000000000, strlen(strcat(name , "\r\n")) , t);
    > + memcpy(c->in_job->body, strcat(name , "\r\n"), strlen(strcat(name , "\r\n")) );
    How many times do you strcat \r\n onto the end of your string?

    You shouldn't even be modifying name at all!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why does this memory scanner crash?
    By Anddos in forum C++ Programming
    Replies: 3
    Last Post: 01-21-2012, 06:03 AM
  2. Why does it crash?
    By Guti14 in forum C++ Programming
    Replies: 14
    Last Post: 06-11-2010, 05:42 PM
  3. stringstream and memory crash
    By fx69 in forum C++ Programming
    Replies: 7
    Last Post: 02-17-2010, 04:42 PM
  4. Crash when freeing memory.
    By Hulag in forum C++ Programming
    Replies: 4
    Last Post: 05-13-2005, 12:44 PM
  5. why's it crash?????
    By stevey in forum C Programming
    Replies: 6
    Last Post: 11-08-2001, 01:52 PM

Tags for this Thread