Fossil SCM

Ensure that UrlData.fossil is always dynamically allocated. Fix a harmless valgrind warnings. Improve comments on UrlData.

drh 2021-10-26 16:11 trunk
Commit cd5715513e2105c0990a31472a5f8b34e43803c0cb434f739f8888da7dd14511
2 files changed +1 +20 -19
--- src/http_socket.c
+++ src/http_socket.c
@@ -243,10 +243,11 @@
243243
*/
244244
void socket_ssh_resolve_addr(UrlData *pUrlData){
245245
struct addrinfo *ai = 0;
246246
struct addrinfo hints;
247247
char zRemote[NI_MAXHOST];
248
+ memset(&hints, 0, sizeof(hints));
248249
hints.ai_family = AF_UNSPEC;
249250
hints.ai_socktype = SOCK_STREAM;
250251
hints.ai_protocol = IPPROTO_TCP;
251252
if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0
252253
&& ai!=0
253254
--- 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 @@
4444
4545
/*
4646
** The URL related data used with this subsystem.
4747
*/
4848
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 */
5555
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 */
6666
char *proxyUrlPath;
67
- int proxyOrigPort; /* Tunneled port number for https through proxy */
67
+ int proxyOrigPort; /* Tunneled port number for https through proxy */
6868
};
6969
#endif /* INTERFACE */
7070
7171
7272
/*
@@ -141,11 +141,11 @@
141141
iStart = 8;
142142
}else if( zUrl[0]=='s' ){
143143
pUrlData->isSsh = 1;
144144
pUrlData->protocol = "ssh";
145145
pUrlData->dfltPort = 22;
146
- pUrlData->fossil = "fossil";
146
+ pUrlData->fossil = fossil_strdup("fossil");
147147
iStart = 6;
148148
}else{
149149
pUrlData->isHttps = 0;
150150
pUrlData->protocol = "http";
151151
pUrlData->dfltPort = 80;
@@ -226,11 +226,11 @@
226226
if( pUrlData->path[i] ){
227227
pUrlData->path[i] = 0;
228228
i++;
229229
}
230230
if( fossil_strcmp(zName,"fossil")==0 ){
231
- pUrlData->fossil = zValue;
231
+ pUrlData->fossil = fossil_strdup(zValue);
232232
dehttpize(pUrlData->fossil);
233233
fossil_free(zExe);
234234
zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil);
235235
cQuerySep = '&';
236236
}
@@ -314,10 +314,11 @@
314314
fossil_free(p->canonical);
315315
fossil_free(p->name);
316316
fossil_free(p->path);
317317
fossil_free(p->user);
318318
fossil_free(p->passwd);
319
+ fossil_free(p->fossil);
319320
memset(p, 0, sizeof(*p));
320321
}
321322
322323
/*
323324
** Parse the given URL, which describes a sync server. Populate variables
324325
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button