X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=marshal.c;h=5f26cff61ce1e1ddf50bbdfce284a3adf443329c;hb=refs%2Fheads%2Fmain;hp=57c40bb78ecb008bff7b840032b960d837cca858;hpb=5e1b22d763640c4d7a09d07920403d8d491b4410;p=onak.git
diff --git a/marshal.c b/marshal.c
index 57c40bb..5f26cff 100644
--- a/marshal.c
+++ b/marshal.c
@@ -13,8 +13,7 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see .
*/
#include
@@ -28,7 +27,7 @@
#include "mem.h"
#include "parsekey.h"
-void marshal_publickey(int (*putchar_func)(void *ctx, size_t count,
+void marshal_publickey(size_t (*putchar_func)(void *ctx, size_t count,
void *c),
void *ctx,
const struct openpgp_publickey *key)
@@ -53,7 +52,7 @@ void marshal_publickey(int (*putchar_func)(void *ctx, size_t count,
free_packet_list(packets);
}
-void marshal_skshash(int (*putchar_func)(void *ctx, size_t count,
+void marshal_skshash(size_t (*putchar_func)(void *ctx, size_t count,
void *c),
void *ctx,
const struct skshash *hash)
@@ -66,14 +65,14 @@ void marshal_skshash(int (*putchar_func)(void *ctx, size_t count,
putchar_func(ctx, sizeof(hash->hash), (void *) hash->hash);
}
-struct skshash *unmarshal_skshash(int (*getchar_func)(void *ctx, size_t count,
+struct skshash *unmarshal_skshash(size_t (*getchar_func)(void *ctx, size_t count,
void *c),
void *ctx)
{
uint32_t len;
struct skshash *hash;
- if (getchar_func(ctx, sizeof(len), &len)) {
+ if (getchar_func(ctx, sizeof(len), &len) != sizeof(len)) {
return NULL;
}
len = ntohl(len);
@@ -81,7 +80,7 @@ struct skshash *unmarshal_skshash(int (*getchar_func)(void *ctx, size_t count,
return NULL;
}
hash = calloc(sizeof(struct skshash), 1);
- if (getchar_func(ctx, len, hash->hash)) {
+ if (getchar_func(ctx, len, hash->hash) != len) {
free(hash);
return NULL;
}
@@ -89,7 +88,7 @@ struct skshash *unmarshal_skshash(int (*getchar_func)(void *ctx, size_t count,
return hash;
}
-void marshal_string(int (*putchar_func)(void *ctx, size_t count,
+void marshal_string(size_t (*putchar_func)(void *ctx, size_t count,
void *c),
void *ctx,
const char *string)
@@ -103,19 +102,19 @@ void marshal_string(int (*putchar_func)(void *ctx, size_t count,
putchar_func(ctx, len, &string);
}
-char *unmarshal_string(int (*getchar_func)(void *ctx, size_t count,
+char *unmarshal_string(size_t (*getchar_func)(void *ctx, size_t count,
void *c),
void *ctx)
{
uint32_t len;
char *string;
- if (getchar_func(ctx, sizeof(len), &len)) {
+ if (getchar_func(ctx, sizeof(len), &len) != sizeof(len)) {
return NULL;
}
len = ntohl(len);
string = malloc(len + 1);
- if (getchar_func(ctx, len, string)) {
+ if (getchar_func(ctx, len, string) != len) {
free(string);
return NULL;
}
@@ -124,10 +123,10 @@ char *unmarshal_string(int (*getchar_func)(void *ctx, size_t count,
return string;
}
-void marshal_array(int (*putchar_func)(void *ctx, size_t count,
+void marshal_array(size_t (*putchar_func)(void *ctx, size_t count,
void *c),
void *ctx,
- void (*marshal_func)(int
+ void (*marshal_func)(size_t
(*putchar_func)(void *ctx,
size_t count, void *c),
void *ctx, const void *item),
@@ -146,10 +145,10 @@ void marshal_array(int (*putchar_func)(void *ctx, size_t count,
}
}
-void **unmarshal_array(int (*getchar_func)(void *ctx, size_t count,
+void **unmarshal_array(size_t (*getchar_func)(void *ctx, size_t count,
void *c),
void *ctx,
- void *(*unmarshal_func)(int
+ void *(*unmarshal_func)(size_t
(*getchar_func)(void *ctx,
size_t count, void *c),
void *ctx),
@@ -159,7 +158,7 @@ void **unmarshal_array(int (*getchar_func)(void *ctx, size_t count,
void **array;
int i;
- if (getchar_func(ctx, sizeof(len), &len)) {
+ if (getchar_func(ctx, sizeof(len), &len) != sizeof(len)) {
return NULL;
}
*size = ntohl(len);