简体   繁体   English

“Syscall param open(mode)在开放的sys调用中包含未初始化的字节”

[英]“Syscall param open(mode) contains uninitialised byte(s)” in open sys call

fd = open(pathname, O_WRONLY | O_LARGEFILE | O_APPEND | O_CREAT);

When running my tests I encounter a valgrind error: 运行我的测试时遇到valgrind错误:

==14280== Syscall param open(mode) contains uninitialised byte(s)
==14280==    at 0x4111084: open64 (open64.c:42)

And the return value of open is -2 并且open的返回值是-2

Errno is set to 13 (Permission denied) Errno被设置为13 (Permission denied)

The pathname buffer contains: pathname缓冲区包含:

0x68
0x72
0x32
0x2E
0x66
0x61
0x0 

Info about my system: 关于我的系统的信息:

$ ls -la
drwxr-xr-x 7 rzetterberg zed 4096 Jul  4 13:56 .
$ id
uid=1000(rzetterberg) gid=1000(rzetterberg) groups=1000(rzetterberg), ... etc
$ sudo file -Ls /dev/sda1
/dev/sda1: sticky Linux rev 1.0 ext3 filesystem data, UUID=XXXX (needs journal recovery) (large files)
$ uname -a
Linux xxxx 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux

Headers included: 标题包括:

#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

I don't understand how mode can have unitialised bytes and why I'm getting a Permission denied . 我不明白mode如何具有单位化字节以及为什么我的Permission denied It seems very strange to me! 这对我来说似乎很奇怪!

If you supply the O_CREAT flag to open() , you must supply a third argument. 如果为open()提供O_CREAT标志,则必须提供第三个参数。 This is an integer which represents the permissions to apply to the created file (modified by the current umask ). 这是一个整数,表示应用于创建文件的权限(由当前umask修改)。

When you call open with O_CREAT you need a third argument to the system call. 当您使用O_CREAT调用open ,您需要系统调用的第三个参数。 That parameter is called mode . 该参数称为mode Valgrind is reporting uninitialized bytes because it doesn't know that you didn't specify the argument, but it sees that whatever happened to be on the stack isn't what it expects. Valgrind报告未初始化的字节,因为它不知道你没有指定参数,但是它发现堆栈上发生的任何事情并不是它所期望的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C-当调用sigqueue时,Valgrind报告“ Syscall参数指向未初始化的字节” - C - Valgrind reporting “Syscall param points to uninitialised byte” when sigqueue call Syscall参数msgsnd(msgp-&gt; mtext)指向未初始化的字节-消息队列-Valgrind - Syscall param msgsnd(msgp->mtext) points to uninitialised byte(s) - Message queues - Valgrind Valgrind奇怪的“Syscall param socketcall.sendto(msg)指向未初始化的字节” - Valgrind strange “Syscall param socketcall.sendto(msg) points to uninitialised byte(s)” Valgrind macOs和错误Syscall param msg-&gt; desc.port.name指向未初始化的字节 - Valgrind macOs and error Syscall param msg->desc.port.name points to uninitialised byte(s) 使用fwrite将结构写入文件时,Valgrind错误-Syscall参数写入(buf)指向未初始化的字节 - Valgrind error when writing struct to file with fwrite - Syscall param write(buf) points to uninitialised byte(s) Silence valgrind param write(buf) 指向未初始化的字节 - Silence valgrind param write(buf) points to uninitialised byte(s) 打开系统调用模式参数编号混淆 - open syscall mode argument number confusion 在Valgrind中获取“Syscall param execve(argv)指向不可寻址的字节” - Getting “Syscall param execve(argv) points to unaddressable byte(s)” in valgrind linux 系统调用 open() 位掩码 - linux syscall open() bitmask 在fifo上打开syscall不会阻止? - open syscall on fifo not blocking?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM