mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Bugs Reporter <bugs@compiler.ai>
To: musl@lists.openwall.com
Cc: sbansal@iitd.ac.in, shubhani@sit.iitd.ac.in,
	abhishek.rose@cse.iitd.ac.in,  Jai.Arora.cs518@cse.iitd.ac.in
Subject: [musl] Bug in swab
Date: Wed, 28 Dec 2022 17:01:53 +0530	[thread overview]
Message-ID: <CAB_V0MBDH4MgXunpj67uz7fb1+f2qOS+kTsw0kSJG4P4HF3xLw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]

Hi,

I am writing to report a bug in the swab function of musl.
The bug is in the C implementation of swab as located in the src/string
directory of the musl repository. The musl version was `1.2.3` and the
source code was downloaded from the latest release
<https://musl.libc.org/releases/musl-1.2.3.tar.gz> on the official website.
Please find a detailed report below.

Linux[0] manpage for swab() specifies that the function copies n bytes from
the array pointed to by from to the array pointed to by to, exchanging
adjacent even and odd bytes. This should also work for coinciding memories
and musl's implementation does not take that into account.
An example input is:
    char src[] = {65, 64};
    void* dst = src;
    swab(src, dst, 2);
    if (src[0] != 64 || src[1] != 65) {
      printf("BUG!\n");
    }

The file that demonstrates the bug can be found here
<https://github.com/compilerai/bug-reports/blob/master/bug_files/musl_swab_bug.c>
.
A patch that applies the necessary fix is available here
<https://github.com/compilerai/bug-reports/blob/master/patch/musl_swab.patch>
.

0: https://man7.org/linux/man-pages/man3/swab.3.html

Thanks,

Jai Arora, Abhishek Rose, Shubhani Gupta, Sorav Bansal
CompilerAI Research Group
IIT Delhi, India

[-- Attachment #2: Type: text/html, Size: 1539 bytes --]

             reply	other threads:[~2022-12-28 11:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28 11:31 Bugs Reporter [this message]
2022-12-28 12:06 ` NRK
2022-12-28 16:20   ` Quentin Rameau
2022-12-29  9:50   ` Alex Xu (Hello71)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAB_V0MBDH4MgXunpj67uz7fb1+f2qOS+kTsw0kSJG4P4HF3xLw@mail.gmail.com \
    --to=bugs@compiler.ai \
    --cc=Jai.Arora.cs518@cse.iitd.ac.in \
    --cc=abhishek.rose@cse.iitd.ac.in \
    --cc=musl@lists.openwall.com \
    --cc=sbansal@iitd.ac.in \
    --cc=shubhani@sit.iitd.ac.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).