@@ -182,7 +182,7 @@ static int ubi_get_num_volume(char *device)
if (dev_id < 0)
return -1;
- sprintf(filename, SYS_UBI_VOLUME_COUNT, dev_id);
+ snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_COUNT, dev_id);
fd = open(filename, O_RDONLY);
if (fd < 0)
return -1;
@@ -201,7 +201,7 @@ out:
static int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_MAX_LENGTH])
{
- char filename[DEVNAME_MAX_LENGTH];
+ char filename[80];
char data[DEVNAME_MAX_LENGTH];
int dev_id, fd, n, ret = -1;
@@ -209,7 +209,7 @@ static int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_M
if (dev_id < 0)
return -1;
- sprintf(filename, SYS_UBI_VOLUME_NAME, dev_id, dev_id, vol_id);
+ snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_NAME, dev_id, dev_id, vol_id);
fd = open(filename, O_RDONLY);
if (fd < 0)
return -1;
@@ -554,10 +554,10 @@ static int fileprotect(struct uboot_flash_env *dev, bool on)
}
if(on == false){
- write(fd_force_ro, &c_unprot_char, 1);
+ ret_int = write(fd_force_ro, &c_unprot_char, 1);
} else {
fsync(dev->fd);
- write(fd_force_ro, &c_prot_char, 1);
+ ret_int = write(fd_force_ro, &c_prot_char, 1);
}
close(fd_force_ro);
libubootenv/src/uboot_env.c: In function ‘fileprotect’: libubootenv/src/uboot_env.c:557:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] write(fd_force_ro, &c_unprot_char, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libubootenv/src/uboot_env.c:560:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] write(fd_force_ro, &c_prot_char, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libubootenv/src/uboot_env.c: In function ‘check_env_device.isra.4’: libubootenv/src/uboot_env.c:44:30: warning: ‘__builtin___sprintf_chk’ may write a terminating nul past the end of the destination [-Wformat-overflow=] #define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name" ^ libubootenv/src/uboot_env.c:44:30: note: in definition of macro ‘SYS_UBI_VOLUME_NAME’ #define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:862:0, from libubootenv/src/uboot_env.c:17: /usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 32 and 61 bytes into a destination of size 40 return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Stefano Babic <sbabic@denx.de> --- src/uboot_env.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)