#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
struct private_b64encode *state = (struct private_b64encode *)f->data;
if (strcmp(key, "mode") == 0) {
+ int64_t val;
+
if (value == NULL) {
archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
"mode option requires octal digits");
return (ARCHIVE_FAILED);
}
- state->mode = (int)atol8(value, strlen(value)) & 0777;
+ val = atol8(value, strlen(value));
+ if (val < 0 || val > INT_MAX) {
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
+ "invalid mode option");
+ return (ARCHIVE_FAILED);
+ }
+ state->mode = (int)val & 0777;
return (ARCHIVE_OK);
} else if (strcmp(key, "name") == 0) {
if (value == NULL) {
{
int64_t l;
int digit;
-
+
+ if (char_cnt == 0)
+ return (-1);
+
l = 0;
while (char_cnt-- > 0) {
if (*p >= '0' && *p <= '7')
digit = *p - '0';
else
- break;
+ return (-1);
p++;
+ if (l > (INT64_MAX >> 3))
+ return (-1);
l <<= 3;
l |= digit;
}
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
struct private_uuencode *state = (struct private_uuencode *)f->data;
if (strcmp(key, "mode") == 0) {
+ int64_t val;
+
if (value == NULL) {
archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
"mode option requires octal digits");
return (ARCHIVE_FAILED);
}
- state->mode = (int)atol8(value, strlen(value)) & 0777;
+ val = atol8(value, strlen(value));
+ if (val < 0 || val > INT_MAX) {
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
+ "invalid mode option");
+ return (ARCHIVE_FAILED);
+ }
+ state->mode = (int)val & 0777;
return (ARCHIVE_OK);
} else if (strcmp(key, "name") == 0) {
if (value == NULL) {
{
int64_t l;
int digit;
-
+
+ if (char_cnt == 0)
+ return (-1);
+
l = 0;
while (char_cnt-- > 0) {
if (*p >= '0' && *p <= '7')
digit = *p - '0';
else
- break;
+ return (-1);
p++;
+ if (l > (INT64_MAX >> 3))
+ return (-1);
l <<= 3;
l |= digit;
}