GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:00:38 JST Pleroma-tan Pleroma-tan
    really confused as to why this isnt working though, i just get a glibc memory corruption error

    the copy code worked fine before..? i just put it into a function so i don't have to keep doing it constantly in other programs
    In conversation Friday, 24-Nov-2023 22:00:38 JST from lab.nyanide.com permalink

    Attachments


    1. https://meds.lab.nyanide.com/media/658f8cb584e1fc21876b53cef30f2307f0545f1a9f602416e1b67cb9361b59e6.png
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:02:06 JST Pleroma-tan Pleroma-tan
      in reply to
      fuck, i might have to use memset for the null terminator
      In conversation Friday, 24-Nov-2023 22:02:06 JST permalink
    • Embed this notice
      paula (paula@comp.lain.la)'s status on Friday, 24-Nov-2023 22:05:12 JST paula paula
      in reply to
      @kirby if that were the problem i'd be shocked
      In conversation Friday, 24-Nov-2023 22:05:12 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:05:30 JST Pleroma-tan Pleroma-tan
      in reply to
      • paula
      @paula so it's probably not then, i wonder why this function is fucking up
      In conversation Friday, 24-Nov-2023 22:05:30 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:05:44 JST Pleroma-tan Pleroma-tan
      in reply to
      • paula
      @paula [the file contents function]
      In conversation Friday, 24-Nov-2023 22:05:44 JST permalink
    • Embed this notice
      ロミンちゃん (romin@shitposter.club)'s status on Friday, 24-Nov-2023 22:05:54 JST ロミンちゃん ロミンちゃん
      in reply to
      @kirby
      >fuck, i might have to use memset for the null terminator
      No that's good, your problem is, with ftell, you aren't checking if it's returning -1 (which most definitely is doing it, as the stream given by popen isn't seekable or rewindable)
      In conversation Friday, 24-Nov-2023 22:05:54 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:06:17 JST Pleroma-tan Pleroma-tan
      in reply to
      • ロミンちゃん
      @romin oh shit
      In conversation Friday, 24-Nov-2023 22:06:17 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:08:12 JST Pleroma-tan Pleroma-tan
      in reply to
      • ロミンちゃん
      @romin thank you, now i need to figure out how to read the stupid bullshit from popen properly
      In conversation Friday, 24-Nov-2023 22:08:12 JST permalink
    • Embed this notice
      paula (paula@comp.lain.la)'s status on Friday, 24-Nov-2023 22:08:19 JST paula paula
      in reply to
      @kirby so clue, i took a look at it and doesn't seem to be any obvious errors
      tho i'm still in bed and super eepy
      In conversation Friday, 24-Nov-2023 22:08:19 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      ロミンちゃん (romin@shitposter.club)'s status on Friday, 24-Nov-2023 22:09:33 JST ロミンちゃん ロミンちゃん
      in reply to
      @kirby you need to read on a loop, reallocating the buffer appropriately, until there's no more data left
      In conversation Friday, 24-Nov-2023 22:09:33 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:10:20 JST Pleroma-tan Pleroma-tan
      in reply to
      • ロミンちゃん
      @romin i love tediousness
      In conversation Friday, 24-Nov-2023 22:10:20 JST permalink

      Attachments


      1. https://meds.lab.nyanide.com/media/dd0fb18ab227702ade66bd1a74b37469ac761d5071f82a8465128151e1208d0c.png
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:11:11 JST Pleroma-tan Pleroma-tan
      in reply to
      • paula
      @paula it didnt work because i was using a stream from popen which doesnt let u seek
      In conversation Friday, 24-Nov-2023 22:11:11 JST permalink
    • Embed this notice
      paula (paula@comp.lain.la)'s status on Friday, 24-Nov-2023 22:11:12 JST paula paula
      in reply to
      • paula
      @kirby yeah i really see no problem
      you're saying if you copy paste the function instead of calling it, then it works?
      In conversation Friday, 24-Nov-2023 22:11:12 JST permalink
    • Embed this notice
      ロミンちゃん (romin@shitposter.club)'s status on Friday, 24-Nov-2023 22:11:58 JST ロミンちゃん ロミンちゃん
      in reply to
      @kirby well you're coding in SEE, you get what you deserve
      In conversation Friday, 24-Nov-2023 22:11:58 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:12:19 JST Pleroma-tan Pleroma-tan
      in reply to
      • ロミンちゃん
      @romin yes i do
      In conversation Friday, 24-Nov-2023 22:12:19 JST permalink
      ロミンちゃん likes this.
    • Embed this notice
      翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:14:43 JST 翠星石 翠星石
      in reply to
      @kirby I'm not exactly sure what you're trying to do there.

      If you want to open a file for reading and save it to a buffer for some reason, I would do;
      #include <sys/stat.h>

      FILE *fp = fopen("/home/chris/file", r);

      //get filesize, will be in stat.st_size
      struct stat stat;
      stat(fp, &stat);

      char *sneed = malloc(stat.st_size);

      fread(sneed, 1, stat.st_size), 1, fp);

      puts(sneed);

      free(sneed);
      fclose(fp);


      But that's a terribly broken program, I reckon I can achieve what you want to do much cleaner with like 10 lines.
      In conversation Friday, 24-Nov-2023 22:14:43 JST permalink
    • Embed this notice
      翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:16:17 JST 翠星石 翠星石
      in reply to
      @kirby The reason why the function is breaking is because you're telling it to open a folder as a file, or something else even more broken.
      In conversation Friday, 24-Nov-2023 22:16:17 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:16:26 JST Pleroma-tan Pleroma-tan
      in reply to
      • 翠星石
      @Suiseiseki it's a test program because i want to see how popen works for another project im contributing to

      this function works fine for most cases
      In conversation Friday, 24-Nov-2023 22:16:26 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:16:53 JST Pleroma-tan Pleroma-tan
      in reply to
      • 翠星石
      @Suiseiseki not this case though because popen is fucking <i>gay</i>
      In conversation Friday, 24-Nov-2023 22:16:53 JST permalink
    • Embed this notice
      翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:24:15 JST 翠星石 翠星石
      in reply to
      @kirby Dumping a file to stdout takes 5 lines;
      #include <stdio.h>
      #include <fcntl.h>
      #include <sys/stat.h>
      #include <unistd.h>
      #include <sys/sendfile.h>

      int main()
      {
      /* open file */
      int fp = open("main.c", O_RDONLY);

      /* get file stats */
      struct stat s;
      fstat(fp, &s);

      /* write file directly to stdout, with length from stat */
      sendfile(fileno(stdout), fp, NULL, s.st_size);

      close(fp);

      }
      In conversation Friday, 24-Nov-2023 22:24:15 JST permalink
    • Embed this notice
      Pleroma-tan (kirby@lab.nyanide.com)'s status on Friday, 24-Nov-2023 22:25:43 JST Pleroma-tan Pleroma-tan
      in reply to
      • 翠星石
      @Suiseiseki i just need to copy the contents of a file into a buffer not write it to stdout
      In conversation Friday, 24-Nov-2023 22:25:43 JST permalink
    • Embed this notice
      翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:46:00 JST 翠星石 翠星石
      in reply to
      @kirby Okay, here you go;

      #include <stdio.h>
      #include <fcntl.h>
      #include <sys/stat.h>
      #include <unistd.h>

      int main()
      {
      /* open file */
      int fp = open("main.c", O_RDONLY);

      /* get file stats */
      struct stat s;
      fstat(fp, &s);

      char buffer[s.st_size];
      ssize_t ignored = read(fp, buffer, s.st_size);
      close(fp);

      ignored = write(STDOUT_FILENO, buffer, sizeof(buffer));

      }
      In conversation Friday, 24-Nov-2023 22:46:00 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      ロミンちゃん (romin@shitposter.club)'s status on Friday, 24-Nov-2023 22:51:16 JST ロミンちゃん ロミンちゃん
      in reply to
      • 翠星石

      @kirby @Suiseiseki execl("/bin/cp", "cp", "file1", "file2", (char *) NULL); :l_hehe;

      In conversation Friday, 24-Nov-2023 22:51:16 JST permalink
      Pleroma-tan likes this.
    • Embed this notice
      翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:59:37 JST 翠星石 翠星石
      in reply to
      • ロミンちゃん
      @romin Ah yes, based GNU cp enjoyer.

      Hmm, the rename(2) function is easy to get documentation on, but I wonder where's the copy(2) function?
      In conversation Friday, 24-Nov-2023 22:59:37 JST permalink
      ロミンちゃん likes this.
    • Embed this notice
      Fifo™ (fifo@mastodon.fifo-f.eu)'s status on Saturday, 25-Nov-2023 09:57:06 JST Fifo™ Fifo™
      in reply to

      @kirby nice hostname lol

      In conversation Saturday, 25-Nov-2023 09:57:06 JST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.