Hi,
I am using linux version 4.1.12-112.14.15.el7uek.x86_64
in one of my program where i am reading data into buffer( pnext) however read() returns a valid return value (len =8) but buffer seems to be corrupted (pnext = 0x64726f7773736170 ). is there any chance read() can lead to this corruption? Below is the code snippet:
do you think uninitialized char * pnext; can lead to any kind of corruption
int len = msglen; //we are assign valid length of structure
157 char *pnext;
158
159 do {
160 len = read(fd, pnext, msglen);
161 if (len < 0) {
162 if (errno == EAGAIN ||
163 errno == EWOULDBLOCK ||
164 errno == EINTR) {
165 continue;
166 }
167 else {
168 break;
169 }
170 }
171 if (len > 0) {
172 msglen -= len;
173 pnext += len;
174 }
175 } while (msglen > 0 && len != 0);
I am using linux version 4.1.12-112.14.15.el7uek.x86_64
in one of my program where i am reading data into buffer( pnext) however read() returns a valid return value (len =8) but buffer seems to be corrupted (pnext = 0x64726f7773736170 ). is there any chance read() can lead to this corruption? Below is the code snippet:
do you think uninitialized char * pnext; can lead to any kind of corruption
int len = msglen; //we are assign valid length of structure
157 char *pnext;
158
159 do {
160 len = read(fd, pnext, msglen);
161 if (len < 0) {
162 if (errno == EAGAIN ||
163 errno == EWOULDBLOCK ||
164 errno == EINTR) {
165 continue;
166 }
167 else {
168 break;
169 }
170 }
171 if (len > 0) {
172 msglen -= len;
173 pnext += len;
174 }
175 } while (msglen > 0 && len != 0);