]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/strutl.h
Fix buffer overflow in debListParser::VersionHash()
[apt.git] / apt-pkg / contrib / strutl.h
index a8bbc38af55ef1b04531fdb5aa23e96cdc5161da..a32aaf06d06a95fe8fac3cba613faed65ad6a6ee 100644 (file)
@@ -22,6 +22,9 @@
 #include <cstring>
 #include <vector>
 #include <iostream>
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
 #include <time.h>
 #include <stddef.h>
 
@@ -64,6 +67,21 @@ std::string Base64Encode(const std::string &Str);
 std::string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
 std::string URItoFileName(const std::string &URI);
 std::string TimeRFC1123(time_t Date);
+/** parses time as needed by HTTP/1.1 and Debian files.
+ *
+ * HTTP/1.1 prefers dates in RFC1123 format (but the other two obsolete date formats
+ * are supported to) and e.g. Release files use the same format in Date & Valid-Until
+ * fields.
+ *
+ * Note: datetime strings need to be in UTC timezones (GMT, UTC, Z, +/-0000) to be
+ * parsed. Other timezones will be rejected as invalid. Previous implementations
+ * accepted other timezones, but treated them as UTC.
+ *
+ * @param str is the datetime string to parse
+ * @param[out] time will be the seconds since epoch of the given datetime if
+ *    parsing is successful, undefined otherwise.
+ * @return \b true if parsing was successful, otherwise \b false.
+ */
 bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
 bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
 APT_DEPRECATED_MSG("Use RFC1123StrToTime or FTPMDTMStrToTime as needed instead") bool StrToTime(const std::string &Val,time_t &Result);
@@ -75,7 +93,9 @@ bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base
 bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
 bool Base256ToNum(const char *Str,unsigned long long &Res,unsigned int Len);
 bool Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length);
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+APT_HIDDEN bool Hex2Num(const APT::StringView Str,unsigned char *Num,unsigned int Length);
+#endif
 // input changing string split
 bool TokSplitString(char Tok,char *Input,char **List,
                    unsigned long ListMax);
@@ -88,7 +108,7 @@ std::vector<std::string> VectorizeString(std::string const &haystack, char const
  *
  * \param input The input string.
  *
- * \param sep The seperator to use.
+ * \param sep The separator to use.
  *
  * \param maxsplit (optional) The maximum amount of splitting that
  * should be done .