dj(1): fix segfault when bses are mismatched
This commit is contained in:
parent
f4b97be1f1
commit
2167f35f58
9
src/dj.c
9
src/dj.c
@ -35,15 +35,15 @@ char *program_name = "dj";
|
|||||||
* writing ends of its jockeyed "pipe". User-configurable members are noted
|
* writing ends of its jockeyed "pipe". User-configurable members are noted
|
||||||
* with their relevant options. */
|
* with their relevant options. */
|
||||||
struct Io{
|
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