Displaying 20 results from an estimated 39 matches for "nbdkit_parse_int".
2020 Aug 18
2
Re: [PATCH nbdkit 1/9] server: Add libnbdkit.so.
On 8/18/20 8:53 AM, Richard W.M. Jones wrote:
> On Tue, Aug 18, 2020 at 07:48:43AM -0500, Eric Blake wrote:
>>> +extern int nbdkit_main (int argc, char *argv[]);
>>
>> A bit odd to declare this in a .c; but I don't see any existing
>> decent .h to put it in, nor is it worth adding a new one just for
>> this. So it is fine right here.
>
> Yup, better
2019 Sep 21
2
[PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...PARSING COMMAND LINE PARAMETERS
+=head2 Parsing numbers
+
+There are several functions for parsing numbers. These all deal
+correctly with overflow, out of range and parse errors, and you should
+use them instead of unsafe functions like L<sscanf(3)>, L<atoi(3)> and
+similar.
+
+ int nbdkit_parse_int (const char *what, const char *str, int *r);
+ int nbdkit_parse_unsigned (const char *what,
+ const char *str, unsigned *r);
+ int nbdkit_parse_long (const char *what, const char *str, long *r);
+ int nbdkit_parse_unsigned_long (const char *what,
+...
2020 Aug 19
0
Re: [PATCH nbdkit 1/9] server: Add libnbdkit.so.
...overflow.com/questions/770344/visual-c-linking-plugin-dll-against-exe#comment1772764_770374
This is to use GetProcAddress from the plugin (DLL) to get the address
of symbols in nbdkit.exe. It works a bit like dlsym. I hacked
together a test plugin to try this:
static void
load (void)
{
int (*_nbdkit_parse_int) (const char *what,
const char *str,
int *r) =
GetProcAddress (GetModuleHandle (NULL), "nbdkit_parse_int");
fprintf (stderr, "nbdkit_parse_int addr = %p\n", _nbdkit_parse_int);
void (*_nbdkit_debug) (const char *msg,...
2019 Sep 23
0
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...=head2 Parsing numbers
> +
> +There are several functions for parsing numbers. These all deal
> +correctly with overflow, out of range and parse errors, and you should
> +use them instead of unsafe functions like L<sscanf(3)>, L<atoi(3)> and
> +similar.
> +
> + int nbdkit_parse_int (const char *what, const char *str, int *r);
> + int nbdkit_parse_unsigned (const char *what,
> + const char *str, unsigned *r);
> + int nbdkit_parse_long (const char *what, const char *str, long *r);
> + int nbdkit_parse_unsigned_long (const char *what,
>...
2019 Sep 23
2
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...xisting
parameters had type long (I don't think unsigned long is actually
used) which we passed directly to one of these APIs. To use another
type would involve a slightly awkward check + cast, with the danger
that the code would break on the rarely tested 32 bit platform.
...
> > + int nbdkit_parse_int16_t (const char *what,
> > + const char *str, int16_t *r);
> > + int nbdkit_parse_uint16_t (const char *what,
> > + const char *str, uint16_t *r);
>
> I guess we can add [u]int8_t variants later if a need arises? Or shou...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 2/5] lib: Move code for parsing, passwords and paths into libnbdkit.so.
...and filters to call.
global:
- nbdkit_absolute_path;
- nbdkit_add_extent;
nbdkit_debug;
nbdkit_error;
nbdkit_export_name;
- nbdkit_extents_count;
- nbdkit_extents_free;
- nbdkit_extents_new;
- nbdkit_get_extent;
nbdkit_nanosleep;
- nbdkit_parse_bool;
- nbdkit_parse_int8_t;
- nbdkit_parse_int16_t;
- nbdkit_parse_int32_t;
- nbdkit_parse_int64_t;
- nbdkit_parse_int;
- nbdkit_parse_size;
- nbdkit_parse_uint8_t;
- nbdkit_parse_uint16_t;
- nbdkit_parse_uint32_t;
- nbdkit_parse_uint64_t;
- nbdkit_parse_unsigned;
nbdkit_peer_name;
-...
2019 Sep 23
2
[PATCH nbdkit v2] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...PARSING COMMAND LINE PARAMETERS
+=head2 Parsing numbers
+
+There are several functions for parsing numbers. These all deal
+correctly with overflow, out of range and parse errors, and you should
+use them instead of unsafe functions like L<sscanf(3)>, L<atoi(3)> and
+similar.
+
+ int nbdkit_parse_int (const char *what, const char *str, int *r);
+ int nbdkit_parse_unsigned (const char *what,
+ const char *str, unsigned *r);
+ int nbdkit_parse_int8_t (const char *what,
+ const char *str, int8_t *r);
+ int nbdkit_parse_uint8_t (const char *what,...
2020 Apr 14
3
Re: [nbdkit PATCH v2 1/3] server: Add nbdkit_stdio_safe
...ive
ourselves wiggle room in future in case we suddenly decided that we
needed this to return an error indication? On the other hand, maybe
errors can never happen in any conceivable situation.
> @@ -455,6 +467,10 @@ nbdkit_read_password (const char *value, char **password)
>
> if (nbdkit_parse_int ("password file descriptor", &value[1], &fd) == -1)
> return -1;
> + if (!nbdkit_stdio_safe () && fd < STDERR_FILENO) {
I think this could be clearer written the other way around:
if (fd < STDERR_FILENO && !nbdkit_stdio_safe ()) {
but t...
2019 Sep 23
0
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...@@ -84,6 +84,28 @@ extern void nbdkit_vdebug (const char *msg, va_list args);
>>> extern char *nbdkit_absolute_path (const char *path);
>>> extern int64_t nbdkit_parse_size (const char *str);
>>> extern int nbdkit_parse_bool (const char *str);
>>> +extern int nbdkit_parse_int (const char *what, const char *str,
>>> + int *r);
>>
>> Should we mark 'what' and 'str' as being non-null parameters? But you
>> definitely document 'r' as valid when NULL.
>
> I think we decided to avoid using...
2020 Aug 18
0
[PATCH nbdkit 8/9] include: Prefix all exports with NBDKIT_DLLEXPORT.
...AT_PRINTF (1, 2);
+extern NBDKIT_DLLEXPORT void nbdkit_vdebug (const char *msg, va_list args)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
-extern char *nbdkit_absolute_path (const char *path);
-extern int64_t nbdkit_parse_size (const char *str);
-extern int nbdkit_parse_bool (const char *str);
-extern int nbdkit_parse_int (const char *what, const char *str,
- int *r);
-extern int nbdkit_parse_unsigned (const char *what, const char *str,
- unsigned *r);
-extern int nbdkit_parse_int8_t (const char *what, const char *str,
- int8...
2020 Oct 03
0
[PATCH nbdkit v2 2/3] ip: Add filtering by process ID, user ID and group ID.
...;
+ break;
+
case BAD:
nbdkit_debug ("%s=BAD(!)%s", name, suffix);
break;
@@ -227,6 +238,37 @@ parse_rule (const char *paramname,
return 0;
}
+ if (n >= 4 && ascii_strncasecmp (value, "pid:", 4) == 0) {
+ new_rule->type = PID;
+ if (nbdkit_parse_int ("pid:", &value[4], &new_rule->u.id) == -1)
+ return -1;
+ if (new_rule->u.id <= 0) {
+ nbdkit_error ("pid: parameter out of range");
+ return -1;
+ }
+ return 0;
+ }
+ if (n >= 4 && ascii_strncasecmp (value, "uid:"...
2020 Jun 01
0
[PATCH nbdkit 2/3] server: Disallow -FD for stdin/stdout/stderr.
...n.
+
=head2 Safely interacting with stdin and stdout
int nbdkit_stdio_safe (void);
diff --git a/server/public.c b/server/public.c
index dafdfbae..2e36e43a 100644
--- a/server/public.c
+++ b/server/public.c
@@ -433,8 +433,8 @@ nbdkit_read_password (const char *value, char **password)
if (nbdkit_parse_int ("password file descriptor", &value[1], &fd) == -1)
return -1;
- if (fd == STDIN_FILENO && !nbdkit_stdio_safe ()) {
- nbdkit_error ("stdin is not available for reading password");
+ if (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_F...
2020 Oct 03
2
[PATCH nbdkit 0/2] ip: Add filtering by process ID, user ID and group ID.
These two commits add new APIs and enhance nbdkit-ip-filter to allow
filtering of Unix domain sockets by the client's PID, UID or GID. eg:
nbdkit -U sock --filter=ip ... allow=uid:`id -u` deny=all
Rich.
2020 Mar 23
0
[PATCH nbdkit 2/3] server: Inject API functions for Windows
...t;);
+ exit (EXIT_FAILURE);
+ }
+ functions->verror = nbdkit_verror;
+ functions->vdebug = nbdkit_vdebug;
+ functions->absolute_path = nbdkit_absolute_path;
+ functions->parse_size = nbdkit_parse_size;
+ functions->parse_bool = nbdkit_parse_bool;
+ functions->parse_int = nbdkit_parse_int;
+ functions->parse_unsigned = nbdkit_parse_unsigned;
+ functions->parse_int8_t = nbdkit_parse_int8_t;
+ functions->parse_uint8_t = nbdkit_parse_uint8_t;
+ functions->parse_int16_t = nbdkit_parse_int16_t;
+ functions->parse_uint16_t = nbdkit_parse_uint16_t;
+ functions->pars...
2020 Mar 25
0
Re: nbdkit / mingw support
..., va_list args)
server/log.c:nbdkit_error (const char *fs, ...)
server/log.c:nbdkit_vfprintf(FILE *f, const char *fmt, va_list args)
server/plugins.c:nbdkit_set_error (int err)
server/public.c:nbdkit_absolute_path (const char *path)
server/public.c:nbdkit_realpath (const char *path)
server/public.c:nbdkit_parse_int (const char *what, const char *str, int *rp)
server/public.c:nbdkit_parse_int8_t (const char *what, const char *str, int8_t *rp)
server/public.c:nbdkit_parse_int16_t (const char *what, const char *str, int16_t *rp)
server/public.c:nbdkit_parse_int32_t (const char *what, const char *str, int32_t *rp...
2020 Mar 26
9
[PATCH nbdkit 5/9 patch split 1/5] Create libnbdkit.so.
This is the previous 5/9 patch posted earlier today, split into
reviewable chunks. This passes bisection with -x 'make && make
check', but I didn't work very hard on the commit messages, so I refer
you back to the original patch to explain how it works:
https://www.redhat.com/archives/libguestfs/2020-March/msg00248.html
Rich.
2020 Jun 01
7
server: Fix reading passwords interactively.
https://bugzilla.redhat.com/show_bug.cgi?id=1842440
Patches 1 and 2 address fairly obvious bugs in how we handle reading
passwords from stdin.
There are other ways we may consider fixing these bugs:
- Should password=- always open /dev/tty and ignore stdin entirely?
- Should we make password=-0/-1/-2 work by skipping the close? Or
perhaps reopen the file descriptors on /dev/null after
2020 Aug 18
2
Re: [PATCH nbdkit 1/9] server: Add libnbdkit.so.
...to the nbdkit_main() function in the library.
>
> The reason for this is to allow nbdkit to be compiled on Windows,
> because Windows does not allow shared libraries to contain any
> undefined symbols. nbdkit previously relied on undefined symbols in
> all plugins and filters (eg. nbdkit_parse_int) which get resolved at
> run time by the nbdkit program. In order to make this work on Windows
> we need to have a new library (libnbdkit.so on Linux, but probably
> called something like LIBNBDKIT.DLL on Windows) which will contain
> these symbols, and plugins can then be compiled wit...
2020 Oct 03
7
[PATCH nbdkit v2 0/3] ip: Add filtering by process ID, user ID and group ID.
This is just a simple update to:
https://www.redhat.com/archives/libguestfs/2020-October/msg00015.html
rebased on top of current nbdkit master because I pushed a few simple
refactorings.
Rich.
2020 Mar 26
3
Re: [PATCH nbdkit 5/9 patch split 2/5] lib: Move code for parsing, passwords and paths into libnbdkit.so.
...gt; # The functions we want plugins and filters to call.
> global:
> + nbdkit_absolute_path;
> + nbdkit_add_extent;
> + nbdkit_extents_count;
> + nbdkit_extents_free;
> + nbdkit_extents_new;
> + nbdkit_get_extent;
> + nbdkit_parse_bool;
> + nbdkit_parse_int16_t;
> + nbdkit_parse_int32_t;
> + nbdkit_parse_int64_t;
> + nbdkit_parse_int8_t;
> + nbdkit_parse_int;
> + nbdkit_parse_size;
> + nbdkit_parse_uint16_t;
> + nbdkit_parse_uint32_t;
> + nbdkit_parse_uint64_t;
> + nbdkit_parse_uint8_t;
> + n...