Fossil SCM
Ensure that UrlData.fossil is always dynamically allocated. Fix a harmless valgrind warnings. Improve comments on UrlData.
Commit
cd5715513e2105c0990a31472a5f8b34e43803c0cb434f739f8888da7dd14511
Parent
6d78082cb594cb7…
2 files changed
+1
+20
-19
+1
| --- src/http_socket.c | ||
| +++ src/http_socket.c | ||
| @@ -243,10 +243,11 @@ | ||
| 243 | 243 | */ |
| 244 | 244 | void socket_ssh_resolve_addr(UrlData *pUrlData){ |
| 245 | 245 | struct addrinfo *ai = 0; |
| 246 | 246 | struct addrinfo hints; |
| 247 | 247 | char zRemote[NI_MAXHOST]; |
| 248 | + memset(&hints, 0, sizeof(hints)); | |
| 248 | 249 | hints.ai_family = AF_UNSPEC; |
| 249 | 250 | hints.ai_socktype = SOCK_STREAM; |
| 250 | 251 | hints.ai_protocol = IPPROTO_TCP; |
| 251 | 252 | if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0 |
| 252 | 253 | && ai!=0 |
| 253 | 254 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -243,10 +243,11 @@ | |
| 243 | */ |
| 244 | void socket_ssh_resolve_addr(UrlData *pUrlData){ |
| 245 | struct addrinfo *ai = 0; |
| 246 | struct addrinfo hints; |
| 247 | char zRemote[NI_MAXHOST]; |
| 248 | hints.ai_family = AF_UNSPEC; |
| 249 | hints.ai_socktype = SOCK_STREAM; |
| 250 | hints.ai_protocol = IPPROTO_TCP; |
| 251 | if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0 |
| 252 | && ai!=0 |
| 253 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -243,10 +243,11 @@ | |
| 243 | */ |
| 244 | void socket_ssh_resolve_addr(UrlData *pUrlData){ |
| 245 | struct addrinfo *ai = 0; |
| 246 | struct addrinfo hints; |
| 247 | char zRemote[NI_MAXHOST]; |
| 248 | memset(&hints, 0, sizeof(hints)); |
| 249 | hints.ai_family = AF_UNSPEC; |
| 250 | hints.ai_socktype = SOCK_STREAM; |
| 251 | hints.ai_protocol = IPPROTO_TCP; |
| 252 | if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0 |
| 253 | && ai!=0 |
| 254 |
+20
-19
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -44,29 +44,29 @@ | ||
| 44 | 44 | |
| 45 | 45 | /* |
| 46 | 46 | ** The URL related data used with this subsystem. |
| 47 | 47 | */ |
| 48 | 48 | struct UrlData { |
| 49 | - int isFile; /* True if a "file:" url */ | |
| 50 | - int isHttps; /* True if a "https:" url */ | |
| 51 | - int isSsh; /* True if an "ssh:" url */ | |
| 52 | - int isAlias; /* Input URL was an alias */ | |
| 53 | - char *name; /* Hostname for http: or filename for file: */ | |
| 54 | - char *hostname; /* The HOST: parameter on http headers */ | |
| 49 | + int isFile; /* True if a "file:" url */ | |
| 50 | + int isHttps; /* True if a "https:" url */ | |
| 51 | + int isSsh; /* True if an "ssh:" url */ | |
| 52 | + int isAlias; /* Input URL was an alias */ | |
| 53 | + char *name; /* Hostname for http: or filename for file: */ | |
| 54 | + char *hostname; /* The HOST: parameter on http headers */ | |
| 55 | 55 | const char *protocol; /* "http" or "https" or "ssh" or "file" */ |
| 56 | - int port; /* TCP port number for http: or https: */ | |
| 57 | - int dfltPort; /* The default port for the given protocol */ | |
| 58 | - char *path; /* Pathname for http: */ | |
| 59 | - char *user; /* User id for http: */ | |
| 60 | - char *passwd; /* Password for http: */ | |
| 61 | - char *canonical; /* Canonical representation of the URL */ | |
| 62 | - char *proxyAuth; /* Proxy-Authorizer: string */ | |
| 63 | - char *fossil; /* The fossil query parameter on ssh: */ | |
| 64 | - unsigned flags; /* Boolean flags controlling URL processing */ | |
| 65 | - int useProxy; /* Used to remember that a proxy is in use */ | |
| 56 | + int port; /* TCP port number for http: or https: */ | |
| 57 | + int dfltPort; /* The default port for the given protocol */ | |
| 58 | + char *path; /* Pathname for http: */ | |
| 59 | + char *user; /* User id for http: */ | |
| 60 | + char *passwd; /* Password for http: */ | |
| 61 | + char *canonical; /* Canonical representation of the URL */ | |
| 62 | + char *proxyAuth; /* Proxy-Authorizer: string */ | |
| 63 | + char *fossil; /* The fossil query parameter on ssh: */ | |
| 64 | + unsigned flags; /* Boolean flags controlling URL processing */ | |
| 65 | + int useProxy; /* Used to remember that a proxy is in use */ | |
| 66 | 66 | char *proxyUrlPath; |
| 67 | - int proxyOrigPort; /* Tunneled port number for https through proxy */ | |
| 67 | + int proxyOrigPort; /* Tunneled port number for https through proxy */ | |
| 68 | 68 | }; |
| 69 | 69 | #endif /* INTERFACE */ |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | /* |
| @@ -141,11 +141,11 @@ | ||
| 141 | 141 | iStart = 8; |
| 142 | 142 | }else if( zUrl[0]=='s' ){ |
| 143 | 143 | pUrlData->isSsh = 1; |
| 144 | 144 | pUrlData->protocol = "ssh"; |
| 145 | 145 | pUrlData->dfltPort = 22; |
| 146 | - pUrlData->fossil = "fossil"; | |
| 146 | + pUrlData->fossil = fossil_strdup("fossil"); | |
| 147 | 147 | iStart = 6; |
| 148 | 148 | }else{ |
| 149 | 149 | pUrlData->isHttps = 0; |
| 150 | 150 | pUrlData->protocol = "http"; |
| 151 | 151 | pUrlData->dfltPort = 80; |
| @@ -226,11 +226,11 @@ | ||
| 226 | 226 | if( pUrlData->path[i] ){ |
| 227 | 227 | pUrlData->path[i] = 0; |
| 228 | 228 | i++; |
| 229 | 229 | } |
| 230 | 230 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 231 | - pUrlData->fossil = zValue; | |
| 231 | + pUrlData->fossil = fossil_strdup(zValue); | |
| 232 | 232 | dehttpize(pUrlData->fossil); |
| 233 | 233 | fossil_free(zExe); |
| 234 | 234 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 235 | 235 | cQuerySep = '&'; |
| 236 | 236 | } |
| @@ -314,10 +314,11 @@ | ||
| 314 | 314 | fossil_free(p->canonical); |
| 315 | 315 | fossil_free(p->name); |
| 316 | 316 | fossil_free(p->path); |
| 317 | 317 | fossil_free(p->user); |
| 318 | 318 | fossil_free(p->passwd); |
| 319 | + fossil_free(p->fossil); | |
| 319 | 320 | memset(p, 0, sizeof(*p)); |
| 320 | 321 | } |
| 321 | 322 | |
| 322 | 323 | /* |
| 323 | 324 | ** Parse the given URL, which describes a sync server. Populate variables |
| 324 | 325 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -44,29 +44,29 @@ | |
| 44 | |
| 45 | /* |
| 46 | ** The URL related data used with this subsystem. |
| 47 | */ |
| 48 | struct UrlData { |
| 49 | int isFile; /* True if a "file:" url */ |
| 50 | int isHttps; /* True if a "https:" url */ |
| 51 | int isSsh; /* True if an "ssh:" url */ |
| 52 | int isAlias; /* Input URL was an alias */ |
| 53 | char *name; /* Hostname for http: or filename for file: */ |
| 54 | char *hostname; /* The HOST: parameter on http headers */ |
| 55 | const char *protocol; /* "http" or "https" or "ssh" or "file" */ |
| 56 | int port; /* TCP port number for http: or https: */ |
| 57 | int dfltPort; /* The default port for the given protocol */ |
| 58 | char *path; /* Pathname for http: */ |
| 59 | char *user; /* User id for http: */ |
| 60 | char *passwd; /* Password for http: */ |
| 61 | char *canonical; /* Canonical representation of the URL */ |
| 62 | char *proxyAuth; /* Proxy-Authorizer: string */ |
| 63 | char *fossil; /* The fossil query parameter on ssh: */ |
| 64 | unsigned flags; /* Boolean flags controlling URL processing */ |
| 65 | int useProxy; /* Used to remember that a proxy is in use */ |
| 66 | char *proxyUrlPath; |
| 67 | int proxyOrigPort; /* Tunneled port number for https through proxy */ |
| 68 | }; |
| 69 | #endif /* INTERFACE */ |
| 70 | |
| 71 | |
| 72 | /* |
| @@ -141,11 +141,11 @@ | |
| 141 | iStart = 8; |
| 142 | }else if( zUrl[0]=='s' ){ |
| 143 | pUrlData->isSsh = 1; |
| 144 | pUrlData->protocol = "ssh"; |
| 145 | pUrlData->dfltPort = 22; |
| 146 | pUrlData->fossil = "fossil"; |
| 147 | iStart = 6; |
| 148 | }else{ |
| 149 | pUrlData->isHttps = 0; |
| 150 | pUrlData->protocol = "http"; |
| 151 | pUrlData->dfltPort = 80; |
| @@ -226,11 +226,11 @@ | |
| 226 | if( pUrlData->path[i] ){ |
| 227 | pUrlData->path[i] = 0; |
| 228 | i++; |
| 229 | } |
| 230 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 231 | pUrlData->fossil = zValue; |
| 232 | dehttpize(pUrlData->fossil); |
| 233 | fossil_free(zExe); |
| 234 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 235 | cQuerySep = '&'; |
| 236 | } |
| @@ -314,10 +314,11 @@ | |
| 314 | fossil_free(p->canonical); |
| 315 | fossil_free(p->name); |
| 316 | fossil_free(p->path); |
| 317 | fossil_free(p->user); |
| 318 | fossil_free(p->passwd); |
| 319 | memset(p, 0, sizeof(*p)); |
| 320 | } |
| 321 | |
| 322 | /* |
| 323 | ** Parse the given URL, which describes a sync server. Populate variables |
| 324 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -44,29 +44,29 @@ | |
| 44 | |
| 45 | /* |
| 46 | ** The URL related data used with this subsystem. |
| 47 | */ |
| 48 | struct UrlData { |
| 49 | int isFile; /* True if a "file:" url */ |
| 50 | int isHttps; /* True if a "https:" url */ |
| 51 | int isSsh; /* True if an "ssh:" url */ |
| 52 | int isAlias; /* Input URL was an alias */ |
| 53 | char *name; /* Hostname for http: or filename for file: */ |
| 54 | char *hostname; /* The HOST: parameter on http headers */ |
| 55 | const char *protocol; /* "http" or "https" or "ssh" or "file" */ |
| 56 | int port; /* TCP port number for http: or https: */ |
| 57 | int dfltPort; /* The default port for the given protocol */ |
| 58 | char *path; /* Pathname for http: */ |
| 59 | char *user; /* User id for http: */ |
| 60 | char *passwd; /* Password for http: */ |
| 61 | char *canonical; /* Canonical representation of the URL */ |
| 62 | char *proxyAuth; /* Proxy-Authorizer: string */ |
| 63 | char *fossil; /* The fossil query parameter on ssh: */ |
| 64 | unsigned flags; /* Boolean flags controlling URL processing */ |
| 65 | int useProxy; /* Used to remember that a proxy is in use */ |
| 66 | char *proxyUrlPath; |
| 67 | int proxyOrigPort; /* Tunneled port number for https through proxy */ |
| 68 | }; |
| 69 | #endif /* INTERFACE */ |
| 70 | |
| 71 | |
| 72 | /* |
| @@ -141,11 +141,11 @@ | |
| 141 | iStart = 8; |
| 142 | }else if( zUrl[0]=='s' ){ |
| 143 | pUrlData->isSsh = 1; |
| 144 | pUrlData->protocol = "ssh"; |
| 145 | pUrlData->dfltPort = 22; |
| 146 | pUrlData->fossil = fossil_strdup("fossil"); |
| 147 | iStart = 6; |
| 148 | }else{ |
| 149 | pUrlData->isHttps = 0; |
| 150 | pUrlData->protocol = "http"; |
| 151 | pUrlData->dfltPort = 80; |
| @@ -226,11 +226,11 @@ | |
| 226 | if( pUrlData->path[i] ){ |
| 227 | pUrlData->path[i] = 0; |
| 228 | i++; |
| 229 | } |
| 230 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 231 | pUrlData->fossil = fossil_strdup(zValue); |
| 232 | dehttpize(pUrlData->fossil); |
| 233 | fossil_free(zExe); |
| 234 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 235 | cQuerySep = '&'; |
| 236 | } |
| @@ -314,10 +314,11 @@ | |
| 314 | fossil_free(p->canonical); |
| 315 | fossil_free(p->name); |
| 316 | fossil_free(p->path); |
| 317 | fossil_free(p->user); |
| 318 | fossil_free(p->passwd); |
| 319 | fossil_free(p->fossil); |
| 320 | memset(p, 0, sizeof(*p)); |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | ** Parse the given URL, which describes a sync server. Populate variables |
| 325 |