Page MenuHomeFreeBSD

D35761.id108940.diff
No OneTemporary

D35761.id108940.diff

Index: include/Makefile
===================================================================
--- include/Makefile
+++ include/Makefile
@@ -9,8 +9,8 @@
CLEANFILES= osreldate.h version
SUBDIR= arpa protocols rpcsvc rpc xlocale
SUBDIR_PARALLEL=
-INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
- db.h \
+INCS= a.out.h ar.h assert.h b64.h bitstring.h complex.h cpio.h _ctype.h \
+ ctype.h db.h \
dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
fts.h ftw.h getopt.h glob.h grp.h \
ieeefp.h ifaddrs.h \
Index: include/b64.h
===================================================================
--- /dev/null
+++ include/b64.h
@@ -0,0 +1,7 @@
+#define b64_ntop __b64_ntop
+#define b64_pton __b64_pton
+
+int b64_ntop(unsigned char const *, size_t, char *, size_t);
+int b64_pton(char const *, unsigned char *, size_t);
+
+int b64_pton_partial(char const *, unsigned char **, size_t);
Index: include/resolv.h
===================================================================
--- include/resolv.h
+++ include/resolv.h
@@ -59,6 +59,7 @@
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/socket.h>
+#include <b64.h>
#include <stdio.h>
#include <arpa/nameser.h>
@@ -335,8 +336,6 @@
extern const struct res_sym __p_rcode_syms[];
#endif /* SHARED_LIBBIND */
-#define b64_ntop __b64_ntop
-#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
#define dn_expand __dn_expand
@@ -420,8 +419,6 @@
int sym_ston(const struct res_sym *, const char *, int *);
const char * sym_ntos(const struct res_sym *, int, int *);
const char * sym_ntop(const struct res_sym *, int, int *);
-int b64_ntop(u_char const *, size_t, char *, size_t);
-int b64_pton(char const *, u_char *, size_t);
int loc_aton(const char *, u_char *);
const char * loc_ntoa(const u_char *, char *);
int dn_skipname(const u_char *, const u_char *);
Index: lib/libc/net/Symbol.map
===================================================================
--- lib/libc/net/Symbol.map
+++ lib/libc/net/Symbol.map
@@ -149,6 +149,10 @@
sctp_sendv;
};
+FBSD_1.7 {
+ b64_pton_partial;
+};
+
FBSDprivate_1.0 {
_nsdispatch;
_nsyyerror; /* generated from nslexer.l */
Index: lib/libc/net/base64.c
===================================================================
--- lib/libc/net/base64.c
+++ lib/libc/net/base64.c
@@ -41,17 +41,11 @@
*/
#include <sys/cdefs.h>
+#include <sys/types.h>
__FBSDID("$FreeBSD$");
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
#include <ctype.h>
-#include <resolv.h>
+#include <b64.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -192,14 +186,15 @@
*/
int
-b64_pton(const char *src, u_char *target, size_t targsize)
+b64_pton_partial(const char *src, unsigned char **original, size_t targsize)
{
int tarindex, state, ch;
- u_char nextbyte;
+ unsigned char nextbyte, *target;
char *pos;
state = 0;
tarindex = 0;
+ target = *original;
while ((ch = *src++) != '\0') {
if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
@@ -210,13 +205,13 @@
pos = strchr(Base64, ch);
if (pos == NULL) /* A non-base64 character. */
- return (-1);
+ goto error;
switch (state) {
case 0:
if (target) {
if ((size_t)tarindex >= targsize)
- return (-1);
+ goto error;
target[tarindex] = (pos - Base64) << 2;
}
state = 1;
@@ -224,13 +219,13 @@
case 1:
if (target) {
if ((size_t)tarindex >= targsize)
- return (-1);
+ goto error;
target[tarindex] |= (pos - Base64) >> 4;
nextbyte = ((pos - Base64) & 0x0f) << 4;
if ((size_t)tarindex + 1 < targsize)
target[tarindex + 1] = nextbyte;
else if (nextbyte)
- return (-1);
+ goto error;
}
tarindex++;
state = 2;
@@ -238,13 +233,13 @@
case 2:
if (target) {
if ((size_t)tarindex >= targsize)
- return (-1);
+ goto error;
target[tarindex] |= (pos - Base64) >> 2;
nextbyte = ((pos - Base64) & 0x03) << 6;
if ((size_t)tarindex + 1 < targsize)
target[tarindex + 1] = nextbyte;
else if (nextbyte)
- return (-1);
+ goto error;
}
tarindex++;
state = 3;
@@ -252,7 +247,7 @@
case 3:
if (target) {
if ((size_t)tarindex >= targsize)
- return (-1);
+ goto error;
target[tarindex] |= (pos - Base64);
}
tarindex++;
@@ -273,7 +268,7 @@
switch (state) {
case 0: /* Invalid = in first position */
case 1: /* Invalid = in second position */
- return (-1);
+ goto error;
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
@@ -282,7 +277,7 @@
break;
/* Make sure there is another trailing = sign. */
if (ch != Pad64)
- return (-1);
+ goto error;
ch = *src++; /* Skip the = */
/* Fall through to "single trailing =" case. */
/* FALLTHROUGH */
@@ -294,7 +289,7 @@
*/
for ((void)NULL; ch != '\0'; ch = *src++)
if (!isspace((unsigned char)ch))
- return (-1);
+ goto error;
/*
* Now make sure for cases 2 and 3 that the "extra"
@@ -304,7 +299,7 @@
*/
if (target && (size_t)tarindex < targsize &&
target[tarindex] != 0)
- return (-1);
+ goto error;
}
} else {
/*
@@ -312,8 +307,18 @@
* have no partial bytes lying around.
*/
if (state != 0)
- return (-1);
+ goto error;
}
+ *original = target + tarindex;
return (tarindex);
+error:
+ *original = target + tarindex;
+ return (-1);
+}
+
+int
+b64_pton(const char *src, unsigned char *target, size_t targsize)
+{
+ return b64_pton_partial(src, &target, targsize);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 24, 2:18 PM (15 m, 59 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24107924
Default Alt Text
D35761.id108940.diff (5 KB)

Event Timeline