* 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 <https://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h>
#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)
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)
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);
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;
}
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)
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;
}
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),
}
}
-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),
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);