Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#18349 closed bug (fixed)

getlogin_r return value is wrong in case of too small buffer

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: R1/beta5
Component: - General Version: R1/beta4
Keywords: r1beta4-fixes Cc:
Blocked By: Blocking:
Platform: All

Description

POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin_r.html> specifies that when getlogin_r fails due to a too small buffer passed as argument, the return value is ERANGE:

"[ERANGE]

The value of namesize is smaller than the length of the string to be returned including the terminating null character."

But Haiku r1beta4 returns ENOMEM instead.

How to reproduce (on x86_64):

$ gcc -Wall -ggdb foo.c
$ ./a.out
err = 0
err = -2147483648
    = Out of memory
err = -2147483648
    = Out of memory
err = -2147483648
    = Out of memory

Attachments (1)

foo.c (668 bytes ) - added by bhaible 21 months ago.
test case

Download all attachments as: .zip

Change History (5)

by bhaible, 21 months ago

Attachment: foo.c added

test case

comment:1 by waddlesplash, 21 months ago

Milestone: UnscheduledR1/beta5
Resolution: fixed
Status: newclosed

Fixed in hrev56905.

comment:2 by kallisti5, 21 months ago

Milestone: R1/beta5R1/beta4

cherry-picked to r1beta4 branch. Next update should include.

comment:3 by pulkomandy, 21 months ago

Milestone: R1/beta4R1/beta5

comment:4 by pulkomandy, 21 months ago

Keywords: r1beta4-fixes added
Note: See TracTickets for help on using tickets.