Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return line length from strtrim, not the (un)modified pointer

  • Loading branch information...
commit 2bafbb036ac049626049abbbf24ee16e526497c8 1 parent ae7846b
Dave Reisner authored
Showing with 21 additions and 22 deletions.
  1. +4 −3 burp.c
  2. +16 −18 util.c
  3. +1 −1  util.h
7 burp.c
View
@@ -97,7 +97,7 @@ static long cookie_expire_time(const char *cookie_file, const char *domain,
memmove(&l[0], &l[10], COOKIE_SIZE - 10);
}
- if (*l == '#' || strlen(l) == 0) {
+ if (*l == '#' || *l == '\0') {
continue;
}
@@ -235,9 +235,10 @@ static int read_config_file(void) {
while (fgets(line, BUFSIZ, fp)) {
char *key;
- strtrim(line);
+ size_t linelen;
- if (line[0] == '#' || strlen(line) == 0) {
+ linelen = strtrim(line);
+ if (!linelen || line[0] == '#') {
continue;
}
34 util.c
View
@@ -82,34 +82,32 @@ char *read_stdin(const char *prompt, size_t maxlen, int echo) {
return buf;
}
-char *strtrim(char *str) {
- char *pch = str;
+size_t strtrim(char *str)
+{
+ char *left = str, *right;
- if (str == NULL || *str == '\0') {
- return str;
+ if(!str || *str == '\0') {
+ return 0;
}
- while (isspace(*pch)) {
- pch++;
+ while(isspace((unsigned char)*left)) {
+ left++;
}
-
- if (pch != str) {
- memmove(str, pch, (strlen(pch) + 1));
+ if(left != str) {
+ memmove(str, left, (strlen(left) + 1));
}
- if (*str == '\0') {
- return str;
+ if(*str == '\0') {
+ return 0;
}
- pch = (str + strlen(str) - 1);
-
- while (isspace(*pch)) {
- pch--;
+ right = (char*)rawmemchr(str, '\0') - 1;
+ while(isspace((unsigned char)*right)) {
+ right--;
}
+ *++right = '\0';
- *++pch = '\0';
-
- return str;
+ return right - left;
}
int touch(const char *filename) {
2  util.h
View
@@ -36,7 +36,7 @@
void debug(const char*, ...);
char *read_stdin(const char*, size_t, int);
-char *strtrim(char*);
+size_t strtrim(char*);
int touch(const char*);
#endif /* _BURP_UTIL_H */
Please sign in to comment.
Something went wrong with that request. Please try again.