search for: strndup

Displaying 20 results from an estimated 339 matches for "strndup".

Did you mean: strdup
2011 Jun 24
4
[PATCH 0/2] Correct various strndup() problems
The current implementation of strndup() has some shortcomings that can lead to a fatal error. - If we pass a maximum string length larger than the copied length, we will corrupt some data beyond the end of the newly allocated buffer. - The maximum length does not prevent access to memory beyond the maximum length, which can l...
2003 Nov 24
1
[PATCH] library functions
...geSet 1.247 -> 1.248 # klibc/Makefile 1.102 -> 1.103 # klibc/include/string.h 1.8 -> 1.9 # (new) -> 1.1 klibc/strncasecmp.c # (new) -> 1.1 klibc/strcasecmp.c # (new) -> 1.1 klibc/strndup.c # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/11/24 mort@green.i.bork.org 1.248 # Add a few new library functions: # -strcasecmp # -strncasecmp # -strndup # -Enable strerror() in the Makefile. It was already there, but it wasn't being co...
2011 Jun 10
0
[PATCH] strndup(): Fix possible null pointer dereference
Directly return NULL if malloc failed. Signed-off-by: maximilian attems <max at stro.at> --- usr/klibc/strndup.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/klibc/strndup.c b/usr/klibc/strndup.c index 8b5974a..65afd44 100644 --- a/usr/klibc/strndup.c +++ b/usr/klibc/strndup.c @@ -10,8 +10,10 @@ char *strndup(const char *s, size_t n) int l = n > strlen(s) ? strlen(s...
2020 Aug 26
2
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
On 8/25/20 3:32 PM, Eric Blake wrote: >>> -      keys[optind] = strndup (argv[optind], n); >>> -      if (keys[optind] == NULL) { >>> -        perror ("strndup"); >>> +      CLEANUP_FREE char *key = strndup (argv[optind], n); >>> +      const char *safekey = nbdkit_string_intern (key); >>> +      if (safekey == NUL...
2014 Aug 11
2
[PATCH] p2v: check results of strndup and sscanf
...sh.c b/p2v/ssh.c index 1e9b05c..ff906df 100644 --- a/p2v/ssh.c +++ b/p2v/ssh.c @@ -505,7 +505,16 @@ open_data_connection (struct config *config, int *local_port, int *remote_port) }, ovector, ovecsize)) { case 100: /* Ephemeral port. */ port_str = strndup (&h->buffer[ovector[2]], ovector[3]-ovector[2]); - sscanf (port_str, "%d", remote_port); + if (port_str == NULL) { + set_ssh_error ("not enough memory for strndup"); + mexp_close (h); + return NULL; + } + if (sscanf (port_str, "%d", re...
2020 Feb 17
3
sshd crashes
...t plen = strlen(b64); The call trace is as below, Sshd main function -> sshkey_load_public -> sshkey_try_load_public -> sshkey_read -> sshbuf_b64tod During compilation a warning is thrown. Is this the trigger point for the crash? "sshkey.c", : warning #2223-D: function "strndup" declared implicitly if ((blobcopy = strndup(cp, space)) == NULL) Please help me to resolve this issue. Thank you. -- *With Best Regards* *Shivakumar S*
2010 Mar 25
0
[PATCH 1/3] btrfs-progs: Fix a compile fail by strndup in RHEL5 env
...olei@cn.fujitsu.com> When we compile btrfs-progs in RHEL5(with default gcc 4.1.2 and glibc-2.5-18), we can get following error: cc1: warnings being treated as errors btrfs-list.c: In function ''ino_resolve'': btrfs-list.c:511: warning: implicit declaration of function ''strndup'' btrfs-list.c:511: warning: incompatible implicit declaration of built-in function ''strndup'' make: *** [btrfs-list.o] Error 1 ... cc1: warnings being treated as errors btrfs.c: In function ''split_command'': btrfs.c:168: warning: implicit declaration of fu...
2020 Aug 25
3
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...dditional complications for the caller. Also I imagined that this function would be a true (LISP-style) INTERN, in that it would return a single pointer if called twice with the two equal strings. But I see from the implementation later on that this isn't the case. > - keys[optind] = strndup (argv[optind], n); > - if (keys[optind] == NULL) { > - perror ("strndup"); > + CLEANUP_FREE char *key = strndup (argv[optind], n); > + const char *safekey = nbdkit_string_intern (key); > + if (safekey == NULL) > exit (EXIT_FAILURE); I...
2007 Mar 30
0
strndup.c bug ?
luoyi at test:~/src/klibc.orig/klibc-1.5/usr/klibc$ diff -u strndup.c strndup.c.new --- strndup.c 2007-03-04 09:52:10.000000000 +0800 +++ strndup.c.new 2007-03-29 18:26:29.000000000 +0800 @@ -10,8 +10,9 @@ int l = n > strlen(s) ? strlen(s) + 1 : n + 1; char *d = malloc(l); - if (d) + if (d) { memcpy(d,...
2010 Jun 28
1
[PATCH] Btrgs-progs: Define _GNU_SOURCE for strndup
This fixes: btrfs-list.c: Dans la fonction «ino_resolve» : btrfs-list.c:511: attention : déclaration implicite de la fonction « «strndup» » btrfs-list.c:511: attention : incompatible implicit declaration of built-in function «strndup» make: *** [btrfs-list.o] Erreur 1 and: btrfs.c: Dans la fonction «split_command» : btrfs.c:168: attention : déclaration implicite de la fonction « «strndup» » btrfs.c:168: attention : incompatible im...
2007 Sep 19
0
Patch to replace strndup with malloc/strncpy for the ini plugin
Hi, I am the maintainer for the compiz port on FreeBSD. We do not have strndup, so this patch replaces one other instance of strndup. thanks, robert. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Replace-strndup-with-malloc-and-strncpy.-FreeBSD-do.patch Type: application/mbox Size: 1671 bytes Desc: not available Url : http://lists...
2020 Sep 03
4
[PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.
I'm not sure if this is a GCC bug or a bug in our code, but the attached workaround fixes it for me. Rich.
2020 Aug 26
0
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
On Wed, Aug 26, 2020 at 08:33:39AM -0500, Eric Blake wrote: > On 8/25/20 3:32 PM, Eric Blake wrote: > > >>>-      keys[optind] = strndup (argv[optind], n); > >>>-      if (keys[optind] == NULL) { > >>>-        perror ("strndup"); > >>>+      CLEANUP_FREE char *key = strndup (argv[optind], n); > >>>+      const char *safekey = nbdkit_string_intern (key); > >>>+    ...
2011 Sep 14
1
[nut-commits] svn commit r3226 - trunk/tools/nut-scanner
...p.c Wed Sep 14 12:25:03 2011 (r3226) > @@ -26,6 +26,7 @@ > #include <netinet/in.h> > #include <arpa/inet.h> > #include <stdio.h> > +#include <string.h> > > /* workaround for buggy Net-SNMP config > * from drivers/snmp-ups.h */ If it's for strndup, I fear it will not be enough. AFAIK strndup is not in standard C library on our Solaris version. I have just made some changes to avoid calling strndup, not committed yet. Fred > > Modified: trunk/tools/nut-scanner/scan_usb.c > =======================================================...
2020 Aug 25
0
Re: [nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...may mean a bit more memory usage and/or cleanup time, but so far there were few enough uses that the main benefit (of a lifetime guaranteed by nbdkit, with automatic cleanup without bookkeeping in the plugin) seemed to outweigh the need for more complexity. > >> - keys[optind] = strndup (argv[optind], n); >> - if (keys[optind] == NULL) { >> - perror ("strndup"); >> + CLEANUP_FREE char *key = strndup (argv[optind], n); >> + const char *safekey = nbdkit_string_intern (key); >> + if (safekey == NULL) >>...
2014 Feb 04
2
Re: [PATCH 2/3] New API: part-get-name (RHBZ#593511).
...>= 2 && > + ((value[0] == '\'' && value[value_len - 1] == '\'') || > + (value[0] == '"' && value[value_len - 1] == '"'))) { > + value_len -= 2; > + ++value; > + } > + > + char *ret = strndup (value, value_len); > + if (ret == NULL) { > + reply_with_perror ("strndup"); > + return NULL; > + } > + > + return ret; > +} My spidey sense asks what happens if the value contains quote characters? I wonder if sgdisk escapes them. Rest of the patch looks...
2020 Aug 18
1
Re: [PATCH nbdkit 3/9] server: Add general replacements for missing functions using LIBOBJS.
...> > Function names Implementation Origin > > getdelim, getline general purpose NetBSD under a compatible license > > openlog, syslog, Win32 written by me > vsyslog > > realpath Win32 written by me > > strndup general purpose written by me > > This should do nothing on existing supported platforms. It is only > intended in preparation for porting nbdkit to Windows. > --- > @@ -464,6 +475,15 @@ AS_CASE([$host_os], > AC_MSG_RESULT([$is_windows]) > AC_SUBST([NO_UNDEFI...
2020 Sep 03
1
Re: [PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.
On 9/3/20 4:41 AM, Richard W.M. Jones wrote: > Previously with GCC 10.2 this code produced: > > In function ‘nbdkit_strndup_intern’, > inlined from ‘nbdkit_strdup_intern’ at public.c:839:10: > public.c:827:10: error: ‘strndup’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] > 827 | copy = strndup (str, n); > | ^~~~~~~...
2020 Sep 03
2
Re: [PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.
...oducer is: > > ---------------------------------------------------------------------- > #include <stdio.h> > #include <stdlib.h> > #include <stdint.h> > #include <string.h> > > const char * > copyn (const char *str, size_t n) > { > return strndup (str, n); > } > > const char * > copy (const char *str) > { > return copyn (str, SIZE_MAX); > } > ---------------------------------------------------------------------- > > $ gcc -O2 -Wall -c test.c > In function ‘copyn’, > inlined from ‘copy’ at test.c:1...
2020 Aug 18
0
[PATCH nbdkit 3/9] server: Add general replacements for missing functions using LIBOBJS.
...ce these functions. This includes replacement functions for: Function names Implementation Origin getdelim, getline general purpose NetBSD under a compatible license openlog, syslog, Win32 written by me vsyslog realpath Win32 written by me strndup general purpose written by me This should do nothing on existing supported platforms. It is only intended in preparation for porting nbdkit to Windows. --- configure.ac | 22 +++++++ Makefile.am | 1 + common/replacements/Makefi...