dj(1): fix segfault when bses are mismatched
This commit is contained in:
parent
f4b97be1f1
commit
2167f35f58
7
src/dj.c
7
src/dj.c
@ -38,12 +38,12 @@ struct Io{
|
|||||||
int bs; /* buffer size (-bB) */
|
int bs; /* buffer size (-bB) */
|
||||||
size_t bufuse; /* buffer usage */
|
size_t bufuse; /* buffer usage */
|
||||||
char *buf; /* buffer */
|
char *buf; /* buffer */
|
||||||
int bytes; /* bytes processed */
|
size_t bytes; /* bytes processed */
|
||||||
int fd; /* file descriptor */
|
int fd; /* file descriptor */
|
||||||
int fl; /* file opening flags */
|
int fl; /* file opening flags */
|
||||||
char *fn; /* file name (may be stdin_name or stdout_name) (-io) */
|
char *fn; /* file name (may be stdin_name or stdout_name) (-io) */
|
||||||
int prec; /* partial records processed */
|
size_t prec; /* partial records processed */
|
||||||
int rec; /* records processed */
|
size_t rec; /* records processed */
|
||||||
long seek; /* bytes to seek/skip (will be 0 after skippage) (-sS) */
|
long seek; /* bytes to seek/skip (will be 0 after skippage) (-sS) */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -197,6 +197,7 @@ int main(int argc, char *argv[]){
|
|||||||
noerror = 0;
|
noerror = 0;
|
||||||
for(i = 0; i < 2; ++i){
|
for(i = 0; i < 2; ++i){
|
||||||
io[i].bs = 1024 /* 1 KiB */; /* GNU dd(1) default; POSIX says 512B */
|
io[i].bs = 1024 /* 1 KiB */; /* GNU dd(1) default; POSIX says 512B */
|
||||||
|
io[i].bufuse = 0;
|
||||||
io[i].bytes = 0;
|
io[i].bytes = 0;
|
||||||
io[i].fd = i == 0 ? STDIN_FILENO : STDOUT_FILENO;
|
io[i].fd = i == 0 ? STDIN_FILENO : STDOUT_FILENO;
|
||||||
io[i].fn = i == 0 ? stdin_name : stdout_name;
|
io[i].fn = i == 0 ? stdin_name : stdout_name;
|
||||||
|
Loading…
Reference in New Issue
Block a user