[PATCH acpi] Replace strncpy with strscpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mateusz,

Tyring to understand your point. Why the customer want a string or
an ID without nul termination?
In your case, you put forward an idea that "the thing is NOT related as a
string, instead it is handled with memcmp".

My idea is:

For examle, the variable "signature" is __nonstring so, it does not necessarily 
contain a terminating NUL.
[snip]
      ACPI_COPY_NAMESEG(header.signature, signature);
      strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
      strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);

[/snip]

But the others, oem_id,oem_table_id are not.
So they are strings and deserve to end with nul.
[snip]
struct acpi_table_header {
    char signature[ACPI_NAMESEG_SIZE] __nonstring;  /* ASCII table signature */
    u32 length;     /* Length of table in bytes, including this header */
    u8 revision;        /* ACPI Specification minor version number */
    u8 checksum;        /* To make sum of entire table == 0 */
    char oem_id[ACPI_OEM_ID_SIZE];  /* ASCII OEM identification */
    char oem_table_id[ACPI_OEM_TABLE_ID_SIZE];  /* ASCII OEM table identification */
    u32 oem_revision;   /* OEM revision number */
    char asl_compiler_id[ACPI_NAMESEG_SIZE];    /* ASCII ASL compiler vendor ID */
    u32 asl_compiler_revision;  /* ASL compiler version */
  };
[/snip]
Otherwise, the writer would have added "__nonstring" keyword.

Best Regards,
Baris




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux