* grub-core/fs/ext2.c (grub_ext2_read_symlink): Use memcpy rather
strncpy. * grub-core/fs/jfs.c (grub_jfs_lookup_symlink): Likewise. * grub-core/kern/misc.c (grub_strncpy): Move from here ... * include/grub/misc.h (grub_strncpy): ... to here. Make inline. * grub-core/net/net.c (grub_net_addr_to_str): Use COMPILE_TIME_ASSERT + strcpy rather than strncpy.
This commit is contained in:
parent
8fbe5c7df7
commit
eb03ede014
6 changed files with 29 additions and 19 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/fs/ext2.c (grub_ext2_read_symlink): Use memcpy rather
|
||||||
|
strncpy.
|
||||||
|
* grub-core/fs/jfs.c (grub_jfs_lookup_symlink): Likewise.
|
||||||
|
* grub-core/kern/misc.c (grub_strncpy): Move from here ...
|
||||||
|
* include/grub/misc.h (grub_strncpy): ... to here. Make inline.
|
||||||
|
* grub-core/net/net.c (grub_net_addr_to_str): Use COMPILE_TIME_ASSERT
|
||||||
|
+ strcpy rather than strncpy.
|
||||||
|
|
||||||
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/fs/zfs/zfs.c (nvpair_name): Use correct type for size.
|
* grub-core/fs/zfs/zfs.c (nvpair_name): Use correct type for size.
|
||||||
|
|
|
@ -670,8 +670,8 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
|
||||||
/* If the filesize of the symlink is bigger than
|
/* If the filesize of the symlink is bigger than
|
||||||
60 the symlink is stored in a separate block,
|
60 the symlink is stored in a separate block,
|
||||||
otherwise it is stored in the inode. */
|
otherwise it is stored in the inode. */
|
||||||
if (grub_le_to_cpu32 (diro->inode.size) <= 60)
|
if (grub_le_to_cpu32 (diro->inode.size) <= sizeof (diro->inode.symlink))
|
||||||
grub_strncpy (symlink,
|
grub_memcpy (symlink,
|
||||||
diro->inode.symlink,
|
diro->inode.symlink,
|
||||||
grub_le_to_cpu32 (diro->inode.size));
|
grub_le_to_cpu32 (diro->inode.size));
|
||||||
else
|
else
|
||||||
|
|
|
@ -723,7 +723,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino)
|
||||||
if (!symlink)
|
if (!symlink)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
if (size <= sizeof (data->currinode.symlink.path))
|
if (size <= sizeof (data->currinode.symlink.path))
|
||||||
grub_strncpy (symlink, (char *) (data->currinode.symlink.path), size);
|
grub_memcpy (symlink, (char *) (data->currinode.symlink.path), size);
|
||||||
else if (grub_jfs_read_file (data, 0, 0, 0, size, symlink) < 0)
|
else if (grub_jfs_read_file (data, 0, 0, 0, size, symlink) < 0)
|
||||||
{
|
{
|
||||||
grub_free (symlink);
|
grub_free (symlink);
|
||||||
|
|
|
@ -94,17 +94,6 @@ grub_strcpy (char *dest, const char *src)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
grub_strncpy (char *dest, const char *src, int c)
|
|
||||||
{
|
|
||||||
char *p = dest;
|
|
||||||
|
|
||||||
while ((*p++ = *src++) != '\0' && --c)
|
|
||||||
;
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_printf (const char *fmt, ...)
|
grub_printf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -734,8 +734,8 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf)
|
||||||
switch (target->type)
|
switch (target->type)
|
||||||
{
|
{
|
||||||
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
|
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
|
||||||
/* TRANSLATORS: it refers to the network address. */
|
COMPILE_TIME_ASSERT (sizeof ("temporary") < GRUB_NET_MAX_STR_ADDR_LEN);
|
||||||
grub_strncpy (buf, "temporary", GRUB_NET_MAX_STR_ADDR_LEN);
|
grub_strcpy (buf, "temporary");
|
||||||
return;
|
return;
|
||||||
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
|
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,18 @@
|
||||||
|
|
||||||
void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
|
void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
|
||||||
char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
|
char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
|
||||||
char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
|
|
||||||
|
static inline char *
|
||||||
|
grub_strncpy (char *dest, const char *src, int c)
|
||||||
|
{
|
||||||
|
char *p = dest;
|
||||||
|
|
||||||
|
while ((*p++ = *src++) != '\0' && --c)
|
||||||
|
;
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
grub_stpcpy (char *dest, const char *src)
|
grub_stpcpy (char *dest, const char *src)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue