Thread: Failed to write file in C shared library

  1. #1
    Registered User
    Join Date
    Jul 2020
    Posts
    1

    Failed to write file in C shared library

    Hello.
    I'm trying modify encryption function
    used in securing data payload in VoIP communication. Now, I'm trying modify the encryption function on libsrtp which is used by the Asterisk server. Now, I am testing the implementation of the decryption method on the Asterisk server. I try to do it by writing into the data packet file received by the server. But when I build this libsrtp into a shared library (libsrtp.so.1) and testing with communication, this causes the asterisk to force to stop. Does anyone know why this could happen? The code I wrote into the file I added has been tried in the usual ubuntu terminal using gcc and has been successful. The following code is added.

    Code:
    FILE *fp:
    fp=fopen("/home/ubuntu/Documents/test_decrypt.txt","a+");
    .....................................
    fprintf(fp,"write to file");
    ...................................
    fclose(fp):
    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,169
    Did you compile the lib for the right architecture of your server?
    Code:
    $ file /lib/x86_64-linux-gnu/libssl.so.1.0.0
    /lib/x86_64-linux-gnu/libssl.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, 
    $ file /lib/i386-linux-gnu/libssl.so.1.0.0
    /lib/i386-linux-gnu/libssl.so.1.0.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked,
    > fp=fopen("/home/ubuntu/Documents/test_decrypt.txt","a+");
    You also need to pick a directory that actually exists on the server.
    In addition, make sure that directory is writeable by the UID(s) of the processes which make use of the library.
    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. Replies: 0
    Last Post: 09-17-2019, 07:09 PM
  2. Replies: 0
    Last Post: 09-17-2019, 07:09 PM
  3. cannot find pdb file/injection of runtime library failed
    By methodos in forum Game Programming
    Replies: 1
    Last Post: 06-07-2012, 05:04 PM
  4. Replies: 1
    Last Post: 08-16-2009, 05:49 AM
  5. shared library for QNX
    By ReeV in forum C Programming
    Replies: 3
    Last Post: 05-06-2009, 10:58 AM

Tags for this Thread