59 lines
1.6 KiB
Diff
59 lines
1.6 KiB
Diff
From 5afc6acd0719ed5b5c4e48763237efe9230fb8a7 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Mon, 27 Aug 2018 16:18:26 +0100
|
|
Subject: [PATCH 4/6] data: Fix this plugin to work with 64 bit offsets.
|
|
|
|
It can now handle 64 bit offsets on both 32 and 64 bit platforms.
|
|
---
|
|
plugins/data/data.c | 16 ++++++++--------
|
|
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/plugins/data/data.c b/plugins/data/data.c
|
|
index e61e3be..3d27227 100644
|
|
--- a/plugins/data/data.c
|
|
+++ b/plugins/data/data.c
|
|
@@ -35,6 +35,8 @@
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
+#include <stdint.h>
|
|
+#include <inttypes.h>
|
|
#include <string.h>
|
|
|
|
#if defined(HAVE_GNUTLS) && defined(HAVE_GNUTLS_BASE64_DECODE2)
|
|
@@ -107,25 +109,23 @@ read_base64 (const char *value)
|
|
static int
|
|
read_data (const char *value)
|
|
{
|
|
- size_t offset = 0;
|
|
+ int64_t offset = 0;
|
|
size_t i, len = strlen (value);
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
- int j, n;
|
|
+ int64_t j;
|
|
+ int n;
|
|
char c;
|
|
|
|
- /* XXX Using the %i type specifier limits this plugin to creating
|
|
- * 32 bit data (even on 64 bit platforms).
|
|
- */
|
|
- if (sscanf (&value[i], " @%i%n", &j, &n) == 1) {
|
|
- if (j == -1) {
|
|
+ if (sscanf (&value[i], " @%" SCNi64 "%n", &j, &n) == 1) {
|
|
+ if (j < 0) {
|
|
nbdkit_error ("data parameter @OFFSET must not be negative");
|
|
return -1;
|
|
}
|
|
i += n;
|
|
offset = j;
|
|
}
|
|
- else if (sscanf (&value[i], " %i%n", &j, &n) == 1) {
|
|
+ else if (sscanf (&value[i], " %" SCNi64 "%n", &j, &n) == 1) {
|
|
if (j < 0 || j > 255) {
|
|
nbdkit_error ("data parameter BYTE must be in the range 0..255");
|
|
return -1;
|
|
--
|
|
2.18.0
|
|
|