bugzilla-daemon at bugzilla.mindrot.org
2016-Feb-13 21:30 UTC
[Bug 2540] New: Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
https://bugzilla.mindrot.org/show_bug.cgi?id=2540
Bug ID: 2540
Summary: Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
Product: Portable OpenSSH
Version: 7.1p1
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P5
Component: Miscellaneous
Assignee: unassigned-bugs at mindrot.org
Reporter: wp02855 at gmail.com
Created attachment 2785
--> https://bugzilla.mindrot.org/attachment.cgi?id=2785&action=edit
patch file for this bug report
Hello All,
The code below implements the C function 'strndup()' in
xmalloc.h
and xmalloc.c (for future use, if needed):
--- xmalloc.h.orig 2016-02-13 09:15:50.418982399 -0800
+++ xmalloc.h 2016-02-13 09:16:24.760347010 -0800
@@ -20,6 +20,7 @@
void *xcalloc(size_t, size_t);
void *xreallocarray(void *, size_t, size_t);
char *xstrdup(const char *);
+char *xstrndup(const char *, size_t);
int xasprintf(char **, const char *, ...)
__attribute__((__format__ (printf, 2, 3)))
__attribute__((__nonnull__ (2)));
======================================================================
--- xmalloc.c.orig 2016-02-13 09:33:10.108121542 -0800
+++ xmalloc.c 2016-02-13 09:34:07.203378056 -0800
@@ -79,6 +79,20 @@
return cp;
}
+char *
+xstrndup(const char *str, size_t dst_size)
+{
+ char *cp;
+ size_t len;
+
+ len = strlen(str) + 1;
+ if (len > size)
+ len = size + 1;
+ cp = xmalloc(len);
+ strlcpy(cp, str, len);
+ return cp;
+}
+
int
xasprintf(char **ret, const char *fmt, ...)
{
=====================================================================
I am attaching the patch file(s) to this report...
Bill Parker (wp02855 at gmail dot com)
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Feb-13 21:31 UTC
[Bug 2540] Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
https://bugzilla.mindrot.org/show_bug.cgi?id=2540
Bill Parker <wp02855 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wp02855 at gmail.com
Attachment #2786| |ok?
Flags| |
--- Comment #1 from Bill Parker <wp02855 at gmail.com> ---
Created attachment 2786
--> https://bugzilla.mindrot.org/attachment.cgi?id=2786&action=edit
Patch file for this bug report
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Feb-14 22:15 UTC
[Bug 2540] Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
https://bugzilla.mindrot.org/show_bug.cgi?id=2540
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dtucker at zip.com.au
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
--- Comment #2 from Darren Tucker <dtucker at zip.com.au> ---
(In reply to Bill Parker from comment #0)> for future use, if needed):
Thanks, but I think we should wait until we have an actual need before
we add something.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Feb-14 23:21 UTC
[Bug 2540] Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
https://bugzilla.mindrot.org/show_bug.cgi?id=2540 --- Comment #3 from Darren Tucker <dtucker at zip.com.au> --- To elaborate on my earlier comment: if you'd like to do something like this then you should be able to demonstrate that it's worth doing. For example, by showing that factoring out this code simplifies or shortens existing code significantly, or it fixes a bug in existing code (eg by handling a corner case that the inline code doesn't). -- You are receiving this mail because: You are watching the assignee of the bug. You are watching someone on the CC list of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Aug-02 00:42 UTC
[Bug 2540] Adds xstrndup() to xmalloc.h/xmalloc.c in OpenSSH 7.x
https://bugzilla.mindrot.org/show_bug.cgi?id=2540
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #4 from Damien Miller <djm at mindrot.org> ---
Close all resolved bugs after 7.3p1 release
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
Possibly Parallel Threads
- [Bug 2541] New: Add explicit_bzero() before free() in OpenSSH-7.1p2 for auth1.c/auth2.c/auth2-hostbased.c
- Possible failure to scrub data in file 'openbsd-compat/bsd-cray.c' in OpenSSH-7.1p1
- [Bug 2539] New: Add missing sanity check for read_passphrase() in auth-pam.c
- RE: __ia64__ ifdef in xmalloc.c: "Fix ar.unat handling forfast paths"
- xmalloc symbol in libssh