Skip to content

int getlogin_r(char *buf, size_t len) broken #888

@isavegas

Description

@isavegas

Please use the following bug reporting template to help produce actionable and reproducible issues:

  • A brief description
    Attempting to use the function to get the login id of the user running the executable returns garbled strings, with a different return value each time.
  • Expected results
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main(){
        size_t len = 10;
        char buf[len];
        size_t ret = getlogin_r(buf, len);
        puts(buf);
        return 0;
}

should print out my username, with ret set to 0 to indicate success.

  • Actual results (with terminal output if applicable)

The value of ret is 2, indicating an error.
Depending on the C compiler used, it outputs garbage strings.
���If compiled with GCC or Clang, it prints out a single "unknown char" box.
If compiled with TCC, it prints out a string the size of one's username, composed of aforementioned boxes and random numbers, letters, and symbols.

  • Your Windows build number

14393

  • Steps / commands required to reproduce the error

gcc test.c -o test && ./test

  • Strace of the failing command

Command doesn't fail in this sense.

  • Required packages and commands to install

sudo apt-get install build-essential

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurewsl2Issue/feature applies to WSL 2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions