Here is the latest diff with the bullshit removed and the loop replaced with
strchr.
Index: bin/dd/args.c
===================================================================
RCS file: /cvs/src/bin/dd/args.c,v
retrieving revision 1.25
diff -u -b -w -p -r1.25 args.c
--- bin/dd/args.c 21 May 2014 06:23:02 -0000 1.25
+++ bin/dd/args.c 13 Jul 2014 09:13:18 -0000
@@ -196,8 +196,7 @@ static void
f_count(char *arg)
{
- if ((cpy_cnt = get_bsz(arg)) == 0)
- cpy_cnt = (size_t)-1;
+ cpy_cnt = get_bsz(arg);
}
static void
@@ -323,8 +322,12 @@ get_bsz(char *val)
size_t num, t;
char *expr;
- num = strtoul(val, &expr, 0);
- if (num == SIZE_T_MAX) /* Overflow. */
+ if (strchr(val, '-'))
+ errx(1, "%s: illegal numeric value", oper);
+
+ errno = 0;
+ num = strtoul(val, &expr, 0);
+ if (num == ULONG_MAX && errno == ERANGE) /* Overflow. */
err(1, "%s", oper);
if (expr == val) /* No digits. */
errx(1, "%s: illegal numeric value", oper);
Index: bin/dd/dd.c
===================================================================
RCS file: /cvs/src/bin/dd/dd.c,v
retrieving revision 1.18
diff -u -b -w -p -r1.18 dd.c
--- bin/dd/dd.c 1 Jun 2013 16:46:49 -0000 1.18
+++ bin/dd/dd.c 13 Jul 2014 09:13:18 -0000
@@ -77,7 +77,7 @@ main(int argc, char *argv[])
atexit(summary);
- if (cpy_cnt != (size_t)-1) {
+ if (cpy_cnt != 0) {
while (files_cnt--)
dd_in();
}
On 7/13/2014 2:08 AM, William Orr wrote:
Sorry, the libssl patch was unintentional. I forgot to cvs up -C that
one.
On 7/13/2014 2:05 AM, Ted Unangst wrote:
On Sun, Jul 13, 2014 at 01:52, William Orr wrote:
Hey,
I sent a patch similar to this almost a month ago with no response.
Feedback? Interest?
Yes.
- num = strtoul(val, &expr, 0);
- if (num == SIZE_T_MAX) /* Overflow. */
+ while (isspace(vp[0]))
+ vp++;
+ if (vp[0] == '-')
+ errx(1, "%s: cannot be negative", oper);
+
+ errno = 0;
+ num = strtoul(vp, &expr, 0);
+ if (num == SIZE_T_MAX && errno == ERANGE) /* Overflow. */
I think you can just use strchr to look for a - anywhere in the
string. It shouldn't be anywhere, right? And use ULONG_MAX to match
strtoul.
Index: lib/libssl/src/crypto/conf/conf_api.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/conf/conf_api.c,v
retrieving revision 1.11
diff -u -b -w -p -r1.11 conf_api.c
--- lib/libssl/src/crypto/conf/conf_api.c 23 Jun 2014 22:19:02
-0000 1.11
+++ lib/libssl/src/crypto/conf/conf_api.c 13 Jul 2014 07:43:09 -0000
@@ -295,7 +295,7 @@ _CONF_new_section(CONF *conf, const char
if ((v->section = malloc(i)) == NULL)
goto err;
- memcpy(v->section, section, i);
+ memmove(v->section, section, i);
v->name = NULL;
v->value = (char *)sk;
Unrelated, but also unnecessary. The malloc above makes it clear
v->section is a unique pointer not aliased with section. memcpy is fine.