#18347 closed bug (fixed)

strxfrm return value is wrong

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: R1/beta5
Component: System/POSIX Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strxfrm.html> specifies that the return value of the strxfrm() function is "the length of the transformed string (not including the terminating NUL character)."

The attached program, foo.c, should therefore print a list of bytes of which the last one, and only the last one, is a NUL byte.

But that is not what it does. How to reproduce:

$ gcc -Wall foo.c
$ ./a.out
result has 24 bytes.
result[0] = 0x2C
result[1] = 0x46
result[2] = 0x4E
result[3] = 0x32
result[4] = 0x04
result[5] = 0x2C
result[6] = 0x52
result[7] = 0x2C
result[8] = 0x2E
result[9] = 0x38
result[10] = 0x32
result[11] = 0x44
result[12] = 0x01
result[13] = 0x44
result[14] = 0x96
result[15] = 0x41
result[16] = 0x96
result[17] = 0x09
result[18] = 0x01
result[19] = 0xDC
result[20] = 0xC1
result[21] = 0xDC
result[22] = 0x0B
result[23] = 0x00
result[24] = 0x02

You can see that the second-to-one printed byte is a NUL byte.

Attachments (1)

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

Download all attachments as: .zip

Change History (2)

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 hrev56907.

Note: See TracTickets for help on using tickets.