aboutsummaryrefslogtreecommitdiff
path: root/src/sg_dd.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2019-05-01 15:36:08 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2019-05-01 15:36:08 +0000
commit3a5deb427c87030be41c99aa0b3fa26d9d79ec67 (patch)
tree2361460fc620be67749e562bcc644af77848abd1 /src/sg_dd.c
parentc3da9a6b41cbae7940180645721a35becdd5bc99 (diff)
downloadsg3_utils-3a5deb427c87030be41c99aa0b3fa26d9d79ec67.tar.gz
sg_vpd: add --examine option; gcc-9: suppress warnings; more testing work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@821 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_dd.c')
-rw-r--r--src/sg_dd.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 0dadc6c0..a005ad28 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -1,7 +1,7 @@
/* A utility program for copying files. Specialised for "files" that
* represent devices that understand the SCSI command set.
*
- * Copyright (C) 1999 - 2018 D. Gilbert and P. Allworth
+ * Copyright (C) 1999 - 2019 D. Gilbert and P. Allworth
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -66,7 +66,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "6.05 20181213";
+static const char * version_str = "6.06 20190501";
#define ME "sg_dd: "
@@ -1609,8 +1609,10 @@ main(int argc, char * argv[])
if ('\0' != inf[0]) {
pr2serr("Second IFILE argument??\n");
return SG_LIB_SYNTAX_ERROR;
- } else
- strncpy(inf, buf, INOUTF_SZ - 1);
+ } else {
+ memcpy(inf, buf, INOUTF_SZ - 1);
+ inf[INOUTF_SZ - 1] = '\0';
+ }
} else if (0 == strcmp(key, "iflag")) {
if (process_flags(buf, &iflag)) {
pr2serr(ME "bad argument to 'iflag='\n");
@@ -1625,14 +1627,18 @@ main(int argc, char * argv[])
if ('\0' != outf[0]) {
pr2serr("Second OFILE argument??\n");
return SG_LIB_CONTRADICT;
- } else
- strncpy(outf, buf, INOUTF_SZ - 1);
+ } else {
+ memcpy(outf, buf, INOUTF_SZ - 1);
+ outf[INOUTF_SZ - 1] = '\0';
+ }
} else if (strcmp(key, "of2") == 0) {
if ('\0' != out2f[0]) {
pr2serr("Second OFILE2 argument??\n");
return SG_LIB_CONTRADICT;
- } else
- strncpy(out2f, buf, INOUTF_SZ - 1);
+ } else {
+ memcpy(out2f, buf, INOUTF_SZ - 1);
+ out2f[INOUTF_SZ - 1] = '\0';
+ }
} else if (0 == strcmp(key, "oflag")) {
if (process_flags(buf, &oflag)) {
pr2serr(ME "bad argument to 'oflag='\n");