From f274b56a5751437e8de13c33f73c33bdd33dbc31 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 12 May 2015 14:00:04 +0100 Subject: [PATCH] Const-correctness in the base64 functions. --- misc.c | 4 ++-- misc.h | 4 ++-- ssh.h | 7 ++++--- sshpubk.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/misc.c b/misc.c index a53aa127..c6587ab1 100644 --- a/misc.c +++ b/misc.c @@ -495,7 +495,7 @@ char *chomp(char *str) * Core base64 encoding and decoding routines. */ -void base64_encode_atom(unsigned char *data, int n, char *out) +void base64_encode_atom(const unsigned char *data, int n, char *out) { static const char base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -519,7 +519,7 @@ void base64_encode_atom(unsigned char *data, int n, char *out) out[3] = '='; } -int base64_decode_atom(char *atom, unsigned char *out) +int base64_decode_atom(const char *atom, unsigned char *out) { int vals[4]; int i, v, len; diff --git a/misc.h b/misc.h index 09c102e9..f63cd969 100644 --- a/misc.h +++ b/misc.h @@ -44,8 +44,8 @@ int toint(unsigned); char *fgetline(FILE *fp); char *chomp(char *str); -void base64_encode_atom(unsigned char *data, int n, char *out); -int base64_decode_atom(char *atom, unsigned char *out); +void base64_encode_atom(const unsigned char *data, int n, char *out); +int base64_decode_atom(const char *atom, unsigned char *out); struct bufchain_granule; typedef struct bufchain_tag { diff --git a/ssh.h b/ssh.h index 21ec7870..ec4f1f99 100644 --- a/ssh.h +++ b/ssh.h @@ -651,10 +651,11 @@ int rsakey_pubblob(const Filename *filename, void **blob, int *bloblen, int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase); -extern int base64_decode_atom(char *atom, unsigned char *out); +extern int base64_decode_atom(const char *atom, unsigned char *out); extern int base64_lines(int datalen); -extern void base64_encode_atom(unsigned char *data, int n, char *out); -extern void base64_encode(FILE *fp, unsigned char *data, int datalen, int cpl); +extern void base64_encode_atom(const unsigned char *data, int n, char *out); +extern void base64_encode(FILE *fp, const unsigned char *data, int datalen, + int cpl); /* ssh2_load_userkey can return this as an error */ extern struct ssh2_userkey ssh2_wrong_passphrase; diff --git a/sshpubk.c b/sshpubk.c index fd43725e..f3c55834 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -1276,7 +1276,7 @@ int base64_lines(int datalen) return (datalen + 47) / 48; } -void base64_encode(FILE * fp, unsigned char *data, int datalen, int cpl) +void base64_encode(FILE *fp, const unsigned char *data, int datalen, int cpl) { int linelen = 0; char out[4];